Re: How to Access Window Messages
- From: "Paul G. Tobey [eMVP]" <p space tobey no spam AT no instrument no spam DOT com>
- Date: Tue, 29 Aug 2006 10:48:11 -0700
Remember that not every message sent to every window will go through the
MessageWindow!!! Your other program must be posting the message to *that
specific window handle*!
Paul T.
<andrerus@xxxxxxxxx> wrote in message
news:1156873476.597249.64620@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Even if remove the creaton of a messageBox and put a breakpoint on the
fist useful line on WndProc, nothig change, the appl seems to not
receive any message (no access to WndProc noticed).
What I don't understand is why the WndProc doesn't receive any standard
message, such as tap, keystroke, ecc...
Into the appl I declare an instance of MyMessageWindow passing a ref to
the appl (this), and implement the method to use to treat the message,
according to the sample aforesaid.
Andrea
Paul G. Tobey [eMVP] ha scritto:
MessageWindow *does* work. Maybe you are not posting the message to that
window, though. You don't want to be popping up message boxes during
processing of other messages. Set a breakpoint in the procedure and you
should see your custom message, if you're posting it to the right place.
Paul T.
<andrerus@xxxxxxxxx> wrote in message
news:1156868088.650797.256570@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi,
I'd like to process costumized window messages receiver by my appl. Il
developing in C#, and this avoid me to override WndProc. I tried to use
MessageWindow, following the how to available on MSDN
(http://msdn2.microsoft.com/en-us/library/5143xwd8.aspx), but it seems
to not intercept any message, neither cusomized nor standards (I tried
to monitor which message I received showing it into a MessageBox,
before processing the switch block).
Why this happening? Can anybody suggest me another solution?
Here is my code:
private class MyMsgWin : MessageWindow
{
private FrmMain Frm;
public MyMsgWin(FrmMain frm)
{
this.Frm = frm;
// Register the unique message for this application.
THIS_MSG =
RegisterWindowMessage(
"MESSAGE_55B71366_F217_4061_9FBE_F601FE4EB920");
}
#region Message Registration
// Used to register the special Windows messages
// used for this application.
[DllImport("coredll")]
public static extern UInt32 RegisterWindowMessage(
String Msg);
// Three variables used to store the unique message values.
UInt32 THIS_MSG;
#endregion
protected override void WndProc(ref Message m)
{
MessageBox.Show("received message " + m.Msg);
// switch (m.Msg)
{
// If message is of interest, invoke the method on
the form that
// functions as a callback to perform actions in
response to the message.
if(m.Msg == THIS_MSG)// Detect my message.
//TODO: HandleMessage
}
// Default processing. Don't touch this or you could
cause the
// system to freeze (among other things).
base.WndProc(ref m);
}
}
}
}
The message registered is also registered into an unmanaged portion,
used be the appl, ad usually is sent by the unmanaged portion to the
appl.
Andrea
.
- Follow-Ups:
- Re: How to Access Window Messages
- From: andrerus
- Re: How to Access Window Messages
- References:
- How to Access Window Messages
- From: andrerus
- Re: How to Access Window Messages
- From: Paul G. Tobey [eMVP]
- Re: How to Access Window Messages
- From: andrerus
- How to Access Window Messages
- Prev by Date: Re: How to Access Window Messages
- Next by Date: Re: USB driver not found after cold boot
- Previous by thread: Re: How to Access Window Messages
- Next by thread: Re: How to Access Window Messages
- Index(es):
Relevant Pages
|
Loading