RegisterWindowMessage

Hi,
I am sending windoew message from a c# application to c++(unmanage)
application using this code
System.UInt32 rm= RegisterWindowMessage("12345");

System.IntPtr ptr=(IntPtr)HWND_BROADCAST;

PostMessage(ptr,(int)rm,5,5);

PostMessage(ptr,WM_AAA,5,5);

but the c++(vc-6 mfc) dont catch the message, when i use the
RegisterWindowMessage("12345"); in the c++ application it return a diffrent
number from that in the c# application why?



Thanks.



0
ben_gigi (5)
7/31/2005 6:56:02 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
807 Views

Similar Articles

[PageSpeed] 52

Don't use PostMessage for the broadcast:
"You can also broadcast messages to all top-level windows by specifying HWND_BROADCAST in the 
SendMessage, SendMessageCallback, SendMessageTimeout, or SendNotifyMessage function.
Applications receive messages through the window procedure of their top-level windows. Messages are 
not sent to child windows. Services can receive messages through a window procedure or their service 
control handlers."

"Dave" <ben_gigi@netvision.net.il> wrote in message news:eqwhugflFHA.3960@TK2MSFTNGP12.phx.gbl...
> Hi,
> I am sending windoew message from a c# application to c++(unmanage)
> application using this code
> System.UInt32 rm= RegisterWindowMessage("12345");
>
> System.IntPtr ptr=(IntPtr)HWND_BROADCAST;
>
> PostMessage(ptr,(int)rm,5,5);
>
> PostMessage(ptr,WM_AAA,5,5);
>
> but the c++(vc-6 mfc) dont catch the message, when i use the
> RegisterWindowMessage("12345"); in the c++ application it return a diffrent
> number from that in the c# application why?
>
>
>
> Thanks.
>
>
> 


0
ScotB (233)
7/31/2005 6:13:14 PM
Re: your question about getting different values back -- perhaps you're not really using the same 
string.  If one string is ANSI and the other is Unicode, for instance, I'm not sure you can expect 
the same value -- but I haven't tested that hypothesis.

"Dave" <ben_gigi@netvision.net.il> wrote in message news:eqwhugflFHA.3960@TK2MSFTNGP12.phx.gbl...
> Hi,
> I am sending windoew message from a c# application to c++(unmanage)
> application using this code
> System.UInt32 rm= RegisterWindowMessage("12345");
>
> System.IntPtr ptr=(IntPtr)HWND_BROADCAST;
>
> PostMessage(ptr,(int)rm,5,5);
>
> PostMessage(ptr,WM_AAA,5,5);
>
> but the c++(vc-6 mfc) dont catch the message, when i use the
> RegisterWindowMessage("12345"); in the c++ application it return a diffrent
> number from that in the c# application why?
>
>
>
> Thanks.
>
>
> 


0
ScotB (233)
7/31/2005 6:17:23 PM
Reply:

Similar Artilces:

RegisterWindowMessage
Hi, I am sending windoew message from a c# application to c++(unmanage) application using this code System.UInt32 rm= RegisterWindowMessage("12345"); System.IntPtr ptr=(IntPtr)HWND_BROADCAST; PostMessage(ptr,(int)rm,5,5); PostMessage(ptr,WM_AAA,5,5); but the c++(vc-6 mfc) dont catch the message, when i use the RegisterWindowMessage("12345"); in the c++ application it return a diffrent number from that in the c# application why? Thanks. Don't use PostMessage for the broadcast: "You can also broadcast messages to all top-level windows by specifying HWND_BR...

RegisterWindowMessage vs WM_USER
I read in the documentation that: "Only use RegisterWindowMessage when more than one application must process the same message. For sending private messages within a window class, an application can use any integer in the range WM_USER through 0x7FFF. " It seems much more convenient to use RegisterWindowMessage even within the same app as you can use it inside several dofferent classes and get the same result for the same string without the classes having to know about each other. OTOH if you use WM_USER the messaging ID must be known to all the classes that use it by some form of ...

RegisterWindowMessage, HWND_BROADCAST between exe and dll issue
i have the following problem, that i've been looking at and googling about for past 4 days to no avail. i have an exe, let's call it exe1, that is ours, that runs as some user, "Administrator" in this particular case, on a given machine, that does following: UINT uiStringA = RegisterWindowMessage("StringA") and then has ON_REGISTERED_MESSAGE(uiStringA, stringAHandler); then i have a vendor's exe, that runs as a service under "System" user and that loads 1 standard c dll, which in turn loads 2nd dll, let's call it dll2, which is also ours and m...