Re: can't bring "single instance" tray app to foreground
- From: "David Ching" <dc@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 03 Jul 2007 13:56:30 GMT
"Frank Cusack" <fcusack@xxxxxxxxxxx> wrote in message
news:m2ir91zy2o.fsf@xxxxxxxxxxxxxxxxxx
I meant I added it to AfxMessageBox().
I guess I'm not understanding what you want to have happen when the second
instance detects the first instance. You want some window to display, but
your main window is meant to be hidden. You keep mentioning some "dialog"
but then your code has AfxMessageBox(). So could you please clarify what
exactly you want to come to the foreground?
Damn, confused myself again. I meant, I have the first (already running,
now in the background) instance bring itself to the foreground. It does
this when the new instance posts the message to it. But it doesn't
make it to the foreground unless I do ShowWindow(SW_RESTORE) which is
terrible.
Yes, you don't want to call ShowWindow(SW_RESTORE) on your main window,
because that is meant to be hidden. I think the only reason for the main
window is because something must "own" the tray icon. But this main window
is never to be displayed because it has no useful content. You are right
that the first instance needs to bring the desired window (either dialog or
messagebox) to the foreground... or create itself anew with the foreground
style.
As long as the second instance (foreground app) calls
AllowSetForegroundWindow(), then the first instance can bring it's
window/dialog to the foreground. The concept is that only the app with
the
foreground focus can give it away, by calling AllowSetForegroundWindow.
Any
other process, including the first instance of your app, will be blocked
from having SetForegroundWindow() take effect... at least if the
"foreground
lock timeout", a user setting, is enabled.
hmm, are you saying ASWF() has to be called in the newly launched 2nd
instance? I was only calling it in the first (now running in bg)
instance. If it's that easy of a fix, that will be very cool.
If that's the case, I completely misunderstood how ASWF() works.
Yes, the second instance must be the one to call ASFW(), as it is the one
with the focus, and is the only one that can then allow other apps to
"steal" it.
-- David
.
- Follow-Ups:
- Re: can't bring "single instance" tray app to foreground
- From: Frank Cusack
- Re: can't bring "single instance" tray app to foreground
- References:
- can't bring "single instance" tray app to foreground
- From: Frank Cusack
- Re: can't bring "single instance" tray app to foreground
- From: David Ching
- Re: can't bring "single instance" tray app to foreground
- From: Frank Cusack
- Re: can't bring "single instance" tray app to foreground
- From: David Ching
- Re: can't bring "single instance" tray app to foreground
- From: Frank Cusack
- can't bring "single instance" tray app to foreground
- Prev by Date: Re: Inheritance and MFC
- Next by Date: Re: header file help......
- Previous by thread: Re: can't bring "single instance" tray app to foreground
- Next by thread: Re: can't bring "single instance" tray app to foreground
- Index(es):
Relevant Pages
|