15,979
社区成员
发帖
与我相关
我的任务
分享
BOOL CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam)
{
//hwnd为找到的子窗口,lParam为传递的参数,自定义为父窗口句柄
//这里对找到的子窗口进行处理
//...
EnumChildWindows(hwnd,(WNDENUMPROC)EnumChildProc,(LPARAM)hwnd);//这个好像可以不需要吧
return TRUE;
}
BOOL CALLBACK EnumChildProc;
EnumChildWindows(hParentWnd,(WNDENUMPROC)EnumChildProc,(LPARAM)hParentWnd);
BOOL CALLBACK EnumChildProc(HWND hwnd,LPARAM lParam)
{
//hwnd为找到的子窗口,lParam为传递的参数,自定义为父窗口句柄
//这里对找到的子窗口进行处理
//...
EnumChildWindows(hwnd,(WNDENUMPROC)EnumChildProc,(LPARAM)hwnd);
return TRUE;
}
VOID OutputWindow(HWND hWnd)
{
TCHAR szTitle[256] = {0};
GetWindowText(hWnd, szTitle, sizeof(szTitle) / sizeof(TCHAR));
TCHAR szBuffer[MAX_PATH] = {0};
_sntprintf(szBuffer, sizeof(szBuffer) / sizeof(TCHAR) - 1, _T("HWND(%x), Title(%s)\n"), (UINT)hWnd, szTitle);
OutputDebugString(szBuffer);
}
void EnumChild(HWND hParent)
{
if(hParent != NULL)
{
HWND hChild = GetWindow(hParent, GW_CHILD);
while(hChild != NULL)
{
EnumChild(hChild);
OutputWindow(hChild);
hChild = GetWindow(hChild, GW_HWNDNEXT);
}
}
}