Microsoft is really conservative on its APIs, so you can be confident when you see that messages WM_APP
through 0xBFFF do not conflict with system messages. It would need a major change in Windows API for that rule to be broken, and many other applications would not survive.
The only relevant question is : do you need to use messages in the WM_USER
range or in the WM_APP
range?
MSDN says:
Message numbers in the second range (WM_USER through 0x7FFF) can be defined and used by an application to send messages within a private window class. These values cannot be used to define messages that are meaningful throughout an application because some predefined window classes already define values in this range. For example, predefined control classes such as BUTTON, EDIT, LISTBOX, and COMBOBOX may use these values. Messages in this range should not be sent to other applications unless the applications have been designed to exchange messages and to attach the same meaning to the message numbers.
Message numbers in the third range (0x8000 through 0xBFFF) are available for applications to use as private messages. Messages in this range do not conflict with system messages.
(emphasis mine)
If you explicitly post those messages to a window that is designed to handle them in a specific way and is not a subclass of a Windows control, you can use WM_USER
range. If they are to be handled directly by the message loop (like WM_QUIT
for example), or if in doubt, use the WP_APP
range.
Said differently, as you do not need a lot of such messages and as you want to post them to the UI thread message queue, simply use one in the WM_APP
range that is not already used by your application, and be sure to document it for later maintenance.
WM_APP through 0xBFFF
is to guarantee that messages in this range will never be used by Windows and so I can use them in my application? – AffirmC
. I have edited my question to remove theC++
tag. – Affirm