Re: How to activate another application?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



>I am not a C++ expert and I want to activate another application from my C++
>code (doesn't matter if it is Windows SDK or MFC). First I successfully find
>the handle to the window. For example using hwnd->SendMessage(WM_CLOSE,0,0)
>closes the app I want to activate. But I have tried to use WM_ACTIVATE and
>WM_SETFOCUS to bring this app to the foreground, but it did not seem to have
>any effect. Does anyone have a working code for activating another
>application?

Miroslaw,

If your application is the active foreground window, you can call
SetForegroundWindow to activate the other application. See the
platform SDK documentation on SetForegroundWindow for the restrictions
the OS imposes to prevent focus snatching.

Dave
.



Relevant Pages

  • Re: How to get around new limitations on SetForegroundWindow()?
    ... > is not the proper method for industrial grade app. ... my system is a control and automation system. ... for a given application will connect to the proxy on the host it is told to, ... that only a current foreground app can bring other apps to the foreground. ...
    (microsoft.public.win32.programmer.ui)
  • Re: Previous Instance
    ... I cannot get it to be the foreground window. ... This is not a bug, it's a feature in win2k and XP that stops adds poping to ... > you have other windows visible, when the app becomes visible, it remains ... but it still doesn't have keyboard focus. ...
    (microsoft.public.vb.winapi)
  • Re: osx wish foreground issue
    ... is expected behavior for any app on any platform that is not ... and typically launch stuff using the "open" command (eg open -a ... which does cause the app to go to foreground. ...
    (comp.lang.tcl)
  • Re: How to get around new limitations on SetForegroundWindow()?
    ... is not the proper method for industrial grade app. ... > foreground window. ... > so far, i.e. external device control. ... that server program will not ...
    (microsoft.public.win32.programmer.ui)
  • Re: Bring window to front or alternatives
    ... windows after the system returned from stanby or hibernate? ... this API call won't work if the foreground window is a console window, ... SetForegroundWindow, ... I don't really like to set system wide settings just so my app can work ...
    (microsoft.public.win32.programmer.ui)