DOCERR: Determining Message Removal from WH_GETMESSAGE Hook

Last reviewed: July 23, 1997
Article ID: Q104068
3.00 3.10 WINDOWS kbprg kbdocerr

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows, version 3.1

A WH_GETMESSAGE hook is called each time PeekMessage or GetMessage is called. The wParam parameter of the hook indicates whether the message is being removed from the queue or merely being looked at.

If PeekMessage is called with the PM_NOREMOVE flag, the message will not be removed from the queue. A WH_GETMESSAGE hook is called each time PeekMessage or GetMessage is called, and therefore the hook may be called more than once for the same message if PeekMessage is called with PM_NOREMOVE.

The hook can determine whether the message is being removed by using the information in the wParam parameter. wParam contains the PM_* flags that were used in the PeekMessage call. GetMessage calls PeekMessage with the PM_REMOVE flag. The Windows 3.1 SDK does not document the value of wParam. It will be documented in future versions.

Note that PM_NOREMOVE is defined as 0x0000, and therefore must be used carefully in any Boolean conditional code. Code similar to the following may be used in the hook:

   if (wParam & PM_REMOVE)
       Message is being removed;
   else Message is being looked at but not being removed. The hook
       may be called again for the same message.


Additional reference words: 3.00 3.10 multiple
KBCategory: kbprg kbdocerr
KBSubcategory: UsrHks
Keywords : kb16bitonly


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: July 23, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.