Making a launched process window on top?

Started by
1 comment, last by 21st Century Moose 11 years, 6 months ago
I am using freeprocess to launch and communicate with an external EXE, but the launched window won't activate/become foreground, on top of main program window.
My launched process has window activation code like below, but it doesn't work when the process is launched from my main application:
void Window::Activate()
{
BringWindowToTop(hwnd);
SetWindowPos(hwnd,NULL,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
SetForegroundWindow(hwnd);
SetActiveWindow(hwnd);
SetFocus(hwnd);
current = this;
}

My main application also calls AllowSetForegroundWindow(), to try to give the launched process permission to take the foreground, but it doesn't seem to do anything:
process=CreateProcess("~q"+procpath+"~q "+parameters)
?win32
AllowSetForegroundWindow(process.handle)
?

How can I allow the window of my launched process to become the topmost window?

10x Faster Performance for VR: www.ultraengine.com

Advertisement
The trick is to call AllowSetForegroundWindow after the process is created. You can use -1 for the process handle.

10x Faster Performance for VR: www.ultraengine.com

You could also use the HWND of your program's window for the second paramter (hWndInsertAfter) of your SetWindowPos call.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

This topic is closed to new replies.

Advertisement