-
EnumChildWindows
I have this function, which i use with EnumWindows to put window titles in a list box and it works fine.
Code:
BOOL CALLBACK WindowsToListBox( HWND hwnd, LPARAM lParam )
{
char buff[500];
GetWindowText( hwnd, buff, sizeof( buff ) );
if( strlen( buff ) )
SendMessage( ( HWND ) lParam, LB_ADDSTRING, 0, (LPARAM) buff );
return TRUE;
}
It is called with:
EnumWindows( WindowsToListBox, ( LPARAM ) ListBox );
Where ListBox is a handle to the list box
However when I try to use EnumChildWindows it dosent work. I call it like this
Code:
EnumChildWindows( NULL, WindowsToListBox, ( LPARAM ) ListBox );
MSDN says that "when the first parameter is NULL EnumChildWindows behaves the same as EnumWindows". So how come it don't work?
-
Further investigating reveals that it is producing the system error "Invalid parameter", when I change the NULL to a window handle it works fine. Is there a function to set a handle to the desktop?
-
Eureaka!!!!
All you need to do is use GetDesktopWindow()
Code:
HWND hwnd = GetDesktopWindow();
EnumChildWindows( hwnd, WindowsToListBox, ( LPARAM ) ListBox );
The only thing is it seems to get just about every window there is, including the time. Oh well at least it works now :)
-
Addition
If you only want to check for programs with visible windows open, the next step would be to use the function IsWindowVisible(...);
Example:
Code:
if(IsWindowVisible(hWnd)) AddToList(hWnd);
Where AddToList is your own function to add the window to the list you're constructing.
This, in theory, should stop you picking up the clock, etc. :)