I have this function, which i use with EnumWindows to put window titles in a list box and it works fine.
However when I try to use EnumChildWindows it dosent work. I call it like this
BOOL CALLBACK WindowsToListBox( HWND hwnd, LPARAM lParam )
GetWindowText( hwnd, buff, sizeof( buff ) );
if( strlen( buff ) )
SendMessage( ( HWND ) lParam, LB_ADDSTRING, 0, (LPARAM) buff );
It is called with:
EnumWindows( WindowsToListBox, ( LPARAM ) ListBox );
Where ListBox is a handle to the list box
MSDN says that "when the first parameter is NULL EnumChildWindows behaves the same as EnumWindows". So how come it don't work?
EnumChildWindows( NULL, WindowsToListBox, ( LPARAM ) ListBox );
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?
All you need to do is use GetDesktopWindow()
The only thing is it seems to get just about every window there is, including the time. Oh well at least it works now :)
HWND hwnd = GetDesktopWindow();
EnumChildWindows( hwnd, WindowsToListBox, ( LPARAM ) ListBox );
If you only want to check for programs with visible windows open, the next step would be to use the function IsWindowVisible(...);
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. :)