HOWTO: Define Private Messages for Application Use

Last reviewed: March 6, 1998
Article ID: Q86835
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) version 3.1
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.5, 3.51
        - Microsoft Windows 95
    

SUMMARY

In the Microsoft Windows environment, an application can define a private message for its own use without calling the RegisterWindowMessage API. Message numbers between 0x8000 and 0xBFFF are reserved for this purpose.

For Windows NT and Windows 95, the system defines a new message WM_APP (value 0x8000). Applications can make use of the range WM_APP through 0xBFFF for private messages without conflict. The only requirement is that the .EXE file must be marked version 4.0 (use the linker switch /subsystem:windows,4.0). Windows NT 3.5 and 3.51 and Windows 95 will run applications marked version 4.0.

MORE INFORMATION

The documentation for the WM_USER message lists four ranges of message numbers as follows:

   Message Number           Description
   --------------           -----------

   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 available for use by applications.

   0xC000 through 0xFFFF    String messages for use by applications.

   Greater than 0xFFFF      Reserved by Windows for future use.

When an application subclasses a predefined Windows control or provides a special message in its dialog box procedure, it cannot use a WM_USER+x message to define a new message because the predefined controls use some WM_USER+x messages internally. It was necessary to use the RegisterWindowMessage function to retrieve a unique message number between 0xC000 and 0xFFFF.

To avoid this inconvenience, messages between 0x8000 and 0xBFFF were redefined to make them available to an application. Messages in this range do not conflict with any other messages in the system.

The distinction here is that WM_USER messages are specific to a window class (whether it is a control or a user-defined class), while WM_APP messages are not. While WM_USER messages can be treated as application messages, the danger in doing so is that if any are already pre-defined for a particular window class, they could be misinterpreted upon receipt.


Additional query words: 3.00 3.10
Keywords : UsrMisc
Version : WINNT:3.5,3.51;
Platform : NT Win95 WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 6, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.