Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


Making a launched process window on top?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Josh Klint   GDNet+   -  Reputation: 1354

Like
0Likes
Like

Posted 11 October 2012 - 05:07 PM

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?

Build mobile games with native code

http://www.leadwerks.com


Sponsor:

#2 Josh Klint   GDNet+   -  Reputation: 1354

Like
0Likes
Like

Posted 11 October 2012 - 07:36 PM

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

Build mobile games with native code

http://www.leadwerks.com


#3 mhagain   Crossbones+   -  Reputation: 8281

Like
0Likes
Like

Posted 12 October 2012 - 03:46 AM

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

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS