Re: Trying to close a bubble window that pops up from a tray icon
I figured out the general solution, I do not know why this works when enum windows does not, however here it is:
Code:
#define SEARCH_TEXT_XP2000 "Click here to enter your user name and password for the network"
#define SEARCH_TEXT_VISTA "Click to provide additional information and connect"
void WaitForClick(void)
{
bool Loop = true;
char Buffer[1025];
Buffer[0] = 0;
while ( Loop )
{
HWND h1 = NULL, h2 = NULL;
h1 = FindWindowEx(NULL, h2, "tooltips_class32", NULL);
while ( h1 != NULL )
{
int Len;
Len = (int)SendMessage(h1, WM_GETTEXT, 1024, (LPARAM)Buffer);
CString MatchBuff;
MatchBuff = Buffer;
if ( Len > 2 )
{
if ( (-1 != MatchBuff.Find(SEARCH_TEXT_XP2000)) || (-1 != MatchBuff.Find(SEARCH_TEXT_VISTA)) )
{
// CloseWindow( h1 );
// SendMessage( h1, WM_CLOSE, NULL, NULL );
ShowWindow( h1, SW_HIDE );
Loop = false;
break;
}
}
h2 = h1;
h1 = FindWindowEx(NULL, h2, "tooltips_class32", NULL);
}
}
}
The only side effect of this is that the CloseWindow seems to cause the tool-tip window to become corrupt. When it pops the window up the next time (by going through the steps to get it to show naturally on its own) the window is all the wrong size and looks like a simple, short text box. The SendMessage() with WM_CLOSE seems to have made the window disappear all together and I may need to reboot to get it to show up again.
Once I get it back, Ill try SW_HIDE and maybe that will be gentler and just make it go away without corrupting it. Doesn't clicking on the close gadget in a window send the WM_CLOSE message?
Anyway this is resolved and thanks for all your help.
Bookmarks