Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IsIconic

Status
Not open for further replies.

domenu

Programmer
May 31, 2002
30
BE
Hello,

I have a question about bringing windows to the foreground.
My application enumerates all windows to find a window with a title that contains (parts of) a given title.

When a window is found, it must be brought to the foreground.

I use the following code to do this:

void __fastcall TForm1::Button2Click(TObject *Sender)
{
AnsiString sTest = "notepad";
char *cTest = sTest.c_str();

// enumerate windows
EnumWindows((WNDENUMPROC)ShowAllWindows, (LPARAM)cTest);
}
//----------------------------------------------------------

BOOL CALLBACK ShowAllWindows(HWND hwnd,LPARAM lParam)
{
if (!hwnd) return TRUE; // Not a window
if(!IsWindow(hwnd)) return TRUE;

char pcWinTitle[255];

char* cTitle = (char*)lParam;
AnsiString sTest = (AnsiString)cTitle;

//if(GetWindow(hwnd, GW_OWNER) != NULL)
{
GetWindowText(hwnd, pcWinTitle, 255);

AnsiString sTemp = (AnsiString)pcWinTitle;

if(sTemp.Pos(sTest) != 0)
{

if (IsIconic(hwnd) != 0)
{
ShowWindowAsync(hwnd, SW_RESTORE);
}

// bring it to the foreground
SetForegroundWindow(hwnd);

return false; //stop enumeration
}
}

//continue enumeration
return TRUE;
}

//---------------------------------------------------

This code works fine to show windows that were NOT created with CBuilder5. It does NOT work for all my other CBuilder-programs...

Can anybody tell me what might be the cause of this issue?

Thanks in advance,

nick;

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top