Re: Overridden WndProc not working in some cases?
- From: "Chris Ashley" <chris.ashley2@xxxxxxxxx>
- Date: 29 Oct 2006 01:10:48 -0700
Hi Stoitcho,
Thanks for your response.
I've now identified the problem. In the first and working case the
process of the message being sent was:
C# Win App -> C# DLL (Separate thread) -> Managed C++ Wrapper ->
Unmanaged C++ DLL
The second case where the messages weren't working was:
C# Win App -> C# DLL (Separate thread) -> Managed C++ Wrapper ->
Unmanaged C++ DLL -> Subsequent Unmanaged C++ DLL (in another separate
thread)
If I pass the window handle of my C# Win App (without launching a
separate thread) it seems to work fine and receives all messages.
However if I do what I was doing before which is creating a window in
my C# DLL which was in a separate thread, it doesn't work in the second
case.
I'm not sure if this is .NET behaviour or standard windows behaviour,
but at least I've found a solution (even if it isn't ideal).
Thanks,
Chris
Stoitcho Goutsev (100) wrote:
Chris,
I don't think there are any options. If the message is sent to correct HWND
it should hit the WndProc.
However the .NET application can filterout messages before they are
dispatched to the target window (Application.AddMessageFilter). It is also
possible that the numeric constant for the message is the same as some
constant that .NETinternaly uses, so it gets wrongfully processed by the
framework. If it is possible try to change the constant for this message.
The correct way of doing it is to use RegisterWindowMessage API.
--
HTH
Stoitcho Goutsev (100)
"Chris Ashley" <chris.ashley2@xxxxxxxxx> wrote in message
news:1161936052.072618.323820@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have an empty, invisible form which is just used for receiving
windows messages from other applications. I have overridden the WndProc
like so:
[System.Security.Permissions.PermissionSet(System.Security.Permissions.SecurityAction.Demand,
Name = "FullTrust")]
protected override void WndProc(ref Message m)
{
switch (m.Msg)
{
case ImageFileMsg.MSG_IF_NEW_DATA:
{
ProcessNewDataMessage(m);
break;
}
case ImageFileMsg.MSG_SCREEN_STARTLOG:
{
ProcessNewScreenMessage(m);
break;
}
default:
{
base.WndProc(ref m);
break;
}
}
}
The two messages come from different DLLs, both written in non-MFC C++.
For some reason the first message (MSG_IF_NEW_DATA) hits my app okay,
but the second message (MSG_SCREEN_STARTLOG) doesn't. I can't even see
the second message appear in Spy++ when I attach it to my window... but
I know the C++ DLL it is coming from works okay because a small C++
test app received the messages okay with the exact same calls. Is there
any sort of compilation or configuration option which affects which
messages my form can see?
.
- References:
- Overridden WndProc not working in some cases?
- From: Chris Ashley
- Overridden WndProc not working in some cases?
- Prev by Date: i cant download anything
- Next by Date: Getting the physical path of network drive.
- Previous by thread: Overridden WndProc not working in some cases?
- Next by thread: C# 2.0 DataBinding using the BindingSource in user controls
- Index(es):
Relevant Pages
|