Advertisement

Windows Messages (off-topic)

Started by February 01, 2004 10:24 AM
3 comments, last by Tree Penguin 21 years, 1 month ago
Hi, how do i send custom window messages and catch them in an independant window? Thanks
There is a varitety of ways you could do it, first you would need either the hInstance of the indepenedant window or the HWND handle of it. From there, you can declare certain messages that would be passed to the message queue by:

#define WM_USER+1
or you could do your own
#define WM_MYAPPLICATIONMESSAGE WM_USER+2

that is how you would define the messages, then in your main window just do something like:

SendMessage(hWnd, WM_MYAPPLICATIONMESSAGE, (WPARAM)0, (LPARAM)0);

I didnt look up the parameters for SendMessage but i think that is right, so what that would do is send that message to the message queue of the independent window with the parameters 0 and 0 for the params. YOu could change those to what you want.

I hope that helps you

Also, if you have a problem where you are having trouble getting the HWND of the independent window, you could do something like:

HWND hWnd = FindWindow("Window Name");
or i gues you could use GetModuleHandle() or something. Just look up those functions, you should be able to get the HWND or HINSTANCE real easy of the independant window...

I hope that helps

"What we do in life, echos in eternity" -- Gladiator
"What we do in life, echos in eternity" -- Gladiator
Advertisement
Thanks, this will help me a lot as i don''t see any reason why it won''t work. I''ll try it out as soon as i need it again.
Depending on your use, you may want to use PostMessage instead of send message. PostMessage returns right away. SendMessage doesn''t return until the message has been processed. If you use PostMessage be careful with pointers that you aren''t erasing the object you''re pointing to before it gets used!
Thanks, i think i won''t need PostMessage but it''s handy information anyway.

This topic is closed to new replies.

Advertisement