VC++ EnumChildWindowsProc 枚举子窗体
bool CALLBACK EnumChildWindowsProc(HWND HwndChild,LPARAM lparam)
{
TCHAR Str[255];
GetWindowText(HwndChild,Str,255);
AfxMessageBox(Str);
return TRUE;
}
/*以上是回调函数的书写格式*/
void CEnumDlg::OnOK()
{
HWND H = ::FindWindow(NULL,"窗体侦探");
/* char Str[25];
itoa((int)H,Str,16);
AfxMessageBox(Str);*/这三句不解释;看似简单,但是 itoa,atoi 每次都搞错;
EnumChildWindows(H,(WNDENUMPROC)EnumChildWindowsProc,NULL);//第二参数为回调函数指针,需要转换为WNDENUMPROC类型
}