Re: How to Access Window Messages



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




.



Relevant Pages

  • Re: How to Access Window Messages
    ... And if I would process the message sent to that specific window handle? ... fist useful line on WndProc, nothig change, the appl seems to not ... // Register the unique message for this application. ...
    (microsoft.public.windowsce.app.development)
  • Re: How to Access Window Messages
    ... own window procedure for the window, in place of the one that the guy who ... Paul G. Tobey ha scritto: ... but how can I controll it by my appl? ... // Used to register the special Windows messages ...
    (microsoft.public.windowsce.app.development)
  • Re: How to Access Window Messages
    ... Paul G. Tobey ha scritto: ... fist useful line on WndProc, nothig change, the appl seems to not ... // Register the unique message for this application. ...
    (microsoft.public.windowsce.app.development)
  • Re: How to Access Window Messages
    ... window and then CallWindowProcto call the original one after you've seen ... but how can I controll it by my appl? ... Paul G. Tobey ha scritto: ... // Used to register the special Windows messages ...
    (microsoft.public.windowsce.app.development)
  • Re: How to Access Window Messages
    ... Paul G. Tobey ha scritto: ... window and then CallWindowProcto call the original one after you've seen ... but how can I controll it by my appl? ... // Used to register the special Windows messages ...
    (microsoft.public.windowsce.app.development)

Loading