I'm was using private messages in my application for year like this:
UM_APP_BASE = WM_APP; // WM_APP is declared as WM_APP = $8000; in "Controls" unit.
and then defined my private messages:
UM_EXPLORER_MSG = UM_APP_BASE + 1;
UM_LICENSE_CHANGE_MSG = UM_APP_BASE + 2;
etc...
And use them like this in my class:
procedure UMLicenseChanged(var Message: TMessage); message UM_LICENSE_CHANGE_MSG;
(I also use RegisterWindowMessage
to "talk" to my other applications but that is a different story)
I don't remember what made me decide to use WM_APP
rather than WM_USER
as base in the first place.
The docs says:
The WM_USER constant is used to distinguish between message values that are reserved for use by Windows and values that can be used by an application to send messages within a private window class. There are five ranges of message numbers:
Range Meaning
0 through WM_USER - 1 Messages reserved for use by Windows.
WM_USER through 0x7FFF Integer messages for use by private window classes.
0x8000 through 0xBFFF Messages reserved for future use by Windows.
0xC000 through 0xFFFF String messages for use by applications.
Greater than 0xFFFF Reserved by Windows for future use.
Which means that WM_APP
is "reserved for future use by Windows".
On the other hand Delphi uses CM_BASE = $B000;
which is in that range. and also CN_BASE = $BC00;
How do I define the base message so it wont collide with other messages used both by Windows/Delphi/Other controls?
Which base message is preferred as private for my application? and why?
Should I use WM_USER
instead of WM_APP
? Note that WM_USER
base is used in CommCtrl by Windows also e.g. TB_ENABLEBUTTON = WM_USER + 1
. etc...
I need some insights on this issue.
I read this on my Delphi help API (D5). which is obviously obsolete!
This is probably why I have decided to use WM_APP
.
Still, an explanation about the difference between the two would be nice :)