Board index » cppbuilder » Bring application to foreground again after having award control to other application.

Bring application to foreground again after having award control to other application.


2003-11-28 03:24:51 PM
cppbuilder56
Hello together,
I work with C++Builder V6, VCL, WinXP professional.
My main app starts a second on and hands over control to this second.
After main app gains back control sporadicly it dous not come to foreground.
Here is a code extract:
if (m_hMutex && m_Running) {
// Warten auf Rückkehr
HANDLE hWaitFor[3];
hWaitFor[0] = m_hMutex;
hWaitFor[1] = m_ProcessInfo.hProcess;
hWaitFor[2] = m_ProcessInfo.hThread;
MenuForm->Hide();
KeyForm->Hide();
ProgForm->Hide();
Application->Minimize();
WaitForMultipleObjects(3, hWaitFor, false, INFINITE);
// Kontrolle zurückerhalten
Screen->Cursor = crDefault;
Application->Restore();
Application->BringToFront();
MenuForm->Show();
KeyForm->Show();
ProgForm->Show();
}
Does somebody has me a hint how to improve this ?
Thank you
Fritz
 
 

Re:Bring application to foreground again after having award control to other application.

please try the API
SetForegroundWindow(Handle);
it might work.
Happy programming! :)