Jump to content

[Solved] Making a launched process window active


Josh
 Share

Recommended Posts

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?

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

AllowSetForegroundWindow() has to be called directly after the new process is created. However, you can use -1 for the process handle, which makes things slightly easier.

  • Upvote 1

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...