How to correectly catch WM_COPYDATA ?
-
Hi, I'm struggling with a problem. I want to catch a 'WM_COPYDATA' event that occurs in a C# application. I send a data from a C++ application. The bridge is correctly done I think. So, sometimes it works, usually when my C# application is active. But most of the time, it doesn't work, because when trying to catch the appropriate WM_COPYDATA message in WndProc overrided method of my C# application, the program stays catching a couple of other messages like: WM_WINDOWPOSCHANGED, WM_ACTIVATEAPP, WM_NCACTIVATE, WM_ACTIVATE and so on. Doing so, it almost never catch the WM_COPYDATA message that I sent from my C++ application. Can you help me please ? Thanks. P.S.: I catch messages in my C# application like this: protected override void WndProc(ref Message m) { string g = m.ToString(); if (m.Msg == WM_COPYDATA) { // instructions. } } p.f. Goudjo-Ako Bringing our energy together !
p.f. Goudjo-Ako Bringing our energy together !
-
Hi, I'm struggling with a problem. I want to catch a 'WM_COPYDATA' event that occurs in a C# application. I send a data from a C++ application. The bridge is correctly done I think. So, sometimes it works, usually when my C# application is active. But most of the time, it doesn't work, because when trying to catch the appropriate WM_COPYDATA message in WndProc overrided method of my C# application, the program stays catching a couple of other messages like: WM_WINDOWPOSCHANGED, WM_ACTIVATEAPP, WM_NCACTIVATE, WM_ACTIVATE and so on. Doing so, it almost never catch the WM_COPYDATA message that I sent from my C++ application. Can you help me please ? Thanks. P.S.: I catch messages in my C# application like this: protected override void WndProc(ref Message m) { string g = m.ToString(); if (m.Msg == WM_COPYDATA) { // instructions. } } p.f. Goudjo-Ako Bringing our energy together !
p.f. Goudjo-Ako Bringing our energy together !
You really need to add:
else //Let the normal windows messaging process it.
{
base.DefWndProc(ref m);
}So that other windows messages get handled properly. I don't know if this will fix your issue or not. I am not sure if your C# app will receive the message if it is not active. Ben
-
You really need to add:
else //Let the normal windows messaging process it.
{
base.DefWndProc(ref m);
}So that other windows messages get handled properly. I don't know if this will fix your issue or not. I am not sure if your C# app will receive the message if it is not active. Ben
I already had: base.WndProc(ref m); Isn't it supposed to do the same thing ? I tried what u asked me, but my c# application doesn't receive any information back. thx.
p.f. Goudjo-Ako Bringing our energy together !
-
I already had: base.WndProc(ref m); Isn't it supposed to do the same thing ? I tried what u asked me, but my c# application doesn't receive any information back. thx.
p.f. Goudjo-Ako Bringing our energy together !
-
Yes, I didn't post it. I also tried to use PostMessage instead of SendMessage. But I don't get appropriate results. Any idea ? Thx.
p.f. Goudjo-Ako Bringing our energy together !
-
Yes, I didn't post it. I also tried to use PostMessage instead of SendMessage. But I don't get appropriate results. Any idea ? Thx.
p.f. Goudjo-Ako Bringing our energy together !
-
Have you looked at this article at all: http://www.codeproject.com/csharp/wm_copydata_use.asp[^] It seems this is doing what you want to do. Ben
thanks.
p.f. Goudjo-Ako Bringing our energy together !