Currently, I have a Windows EXE application, with several loaded DLLs. DLLs need to communicate with my windows application through PostMessage
and SendMessage
.
The Windows EXE application + DLLs are all within a single process.
The message should be private among EXE and DLLs.
I was wondering, should I use
- WM_USER based message
- WM_APP based message
- RegisterWindowMessage
and why?
What happen if there is an external process (another exe), trying to FindWindow of my Windows application, and send the message with same ID?
I wish not to respond, as I am only interested message from DLLs within my own process.
WM_USER messages are typically used to implement control specific messages when developing a control. If you had developed an image editing control, and needed to allow users of the control to set the image, you might go:
#define IECM_SETIMAGE (WM_USER+1) // image editor control message.
WM_APP messages are typically used to implement application level logic. If you want to send your application a specific message to perform an action...
#define IEAM_SHOWTOOLBAR (WM_APP+1) // image editor app message
Having both WM_APP and WM_USER ranges seems a little redundant - however there are two use cases where having two ranges is necessary:
RegisterWindowMessage is used to create messages when you need a unique message id that is system wide - typically because you want to broadcast the message to windows that are not under your own control, and hence have their own meanings for messages IDs in the WM_APP and WM_USER ranges.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With