By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,989 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,989 IT Pros & Developers. It's quick & easy.

Too many wm_AppActivates spoil the Application ...

P: n/a
I've written my own replacement for MsgBox, that I do all kinds
of wierd things with. So far, it's done everything I need it to.
Until now ...

I'm trying to use it in an application that is "sensitive" to the
difference between the Activate and AppActivate "events" (the former
being handled by overriding OnActivated, the latter by interrogating
the Message argument to WndProc).

For some odd reason, when I use my MsgBox replacement, I'm
getting not one, but /two/, WM_APPActivate messages in the
calling form - values seen in WndProc:

Msg=(28), hWnd=(3081424), LParam=(2004), WParam=(0)
Msg=(28), hWnd=(3081424), LParam=(2004), WParam=(1)

This triggers all kinds of things in the application that I don't want
to happen for an "internal" dialog. Oddly, using the normal
MsgBox instead, I get /no/ wm_appactivate messages at all!

Since my replacement is little more than a Form within which I call
ShowDialog(owner) on itself, can anyone suggest where these
extraneous messages might be coming from?
Surely the CLR can't see every form in a single application as a separate
application... ?

TIA,
Phill W.

Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Phill. W wrote:
For some odd reason, when I use my MsgBox replacement, I'm
getting not one, but /two/, WM_APPActivate messages in the
calling form - values seen in WndProc:

Msg=(28), hWnd=(3081424), LParam=(2004), WParam=(0)
Msg=(28), hWnd=(3081424), LParam=(2004), WParam=(1)


If I'm not mistake, I believe that the WParam indicates what is
happening. If WParam is False, then the window is being de-activated
and if True, the window is being activated.

Could it be that one message is occurring when the main form is no
longer the active form and the other is when the MsgBox is becoming the
active form?

Just a thought

Nov 21 '05 #2

P: n/a
And after a little research, there should be two messages. One to the
app whose window is being deactivated and one to the app whose window
is being activated.

Nov 21 '05 #3

P: n/a
"Chris Dunaway" <du******@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
And after a little research, there should be two messages. One to
the app whose window is being deactivated and one to the app
whose window is being activated.


After some digging, I found the same thing myself - wm_activateapp's
/do/ come in pairs. However, this still belies my [rather more
significant]
problem in that I wasn't expecting to get /any/ of them in the first place!

My replacement form is in a separate, GAC-"registered" assembly
but, even so, that still shouldn't force execution out into a separate
Thread, should it?

Alternatively, since the wm_activateapp includes the ThreadID of the
"other" process, is there any way I can work out what /my/
application's ThreadId is and only call the "OnAppActivate" code if
the ThreadID's differ? (If I'm regaining "focus" from myself, then it's
not a "genuine" Application Activation).

Regards,
Phill W.
Nov 21 '05 #4

P: n/a
Phill. W wrote:
problem in that I wasn't expecting to get /any/ of them in the first place!
That is my understanding as well. Since the forms are being shown from
the same application, I wouldn't think that that particular message
would occur. Did you see them while in the debugger? Perhaps the act
of switching from the debugger might have had something to do with it.

"other" process, is there any way I can work out what /my/
application's ThreadId is and only call the "OnAppActivate" code if


You can get your thread id by calling AppDomain.GetCurrentThreadId

Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.