I'm looking for a window that its class name is "CLIPBRDWNDCLASS" (it can be found in office apps and other applications).
If I use FindWindow or FindWindowEx I find the first HWND that has this class, but I want all the windows with that class, so I decided to use recursive EnumChildWindows to enumerate all windows and find the window I want:
//-------------------------------------------------------------------------------
BOOL CALLBACK enum_wnd_proc(HWND h, LPARAM lp)
{
char cls[1024] = {0};
::GetClassNameA(h, cls, 1024);
if(std::string(cls) == "CLIPBRDWNDCLASS")
{
// match!
}
::EnumChildWindows(h, enum_wnd_proc, NULL);
return TRUE;
}
//-------------------------------------------------------------------------------
int _tmain(int argc, _TCHAR* argv[])
{
::EnumWindows(enum_wnd_proc, NULL);
return 0;
}
//-------------------------------------------------------------------------------
The this is that this window does not return by the EnumWindows, only by FindWindow.
Does anyone can tell why it doesn't work ???
EnumChildWindows()is already recursive and you don't need to call it again within the callback function. Second, try printing the class names of all the windows you come across and see if it gives you a hint. - Asaf