Important window message numbers to memorize


You probably know them already, but if you're new to Win32, here are some key window messages. I would normally suggest that you commit them to memory, but if you do enough debugging, you'll end up memorizing them anyway because you see them all the time.

0x000F WM_PAINT
0x001A WM_WININICHANGE / WM_SETTINGCHANGE
0x0046 WM_WINDOWPOSCHANGING
0x0047 WM_WINDOWPOSCHANGED
0x004E WM_NOTIFY
0x010n WM_KEYxxx
0x0111 WM_COMMAND
0x0112 WM_SYSCOMMAND
0x0113 WM_TIMER
0x0200 WM_MOUSEMOVE
0x020n WM_MOUSExxx
0x0400 WM_USER
0x8000 WM_APP
0xCxxx RegisterWindowMessage

I include 0x001A in the list even though it is a low-traffic message because you do see it a lot when you are investigating hangs. The WM_SETTINGCHANGE (which also goes by the name WM_WININICHANGE) is a common culprit when investigating why your program has wedged: You're broadcasting a notification and there's a window in the system that isn't responding.

I know that Visual Studio has a shortcut for decoding error codes. I wonder if it has one for decoding message numbers.

Comments (11)
  1. bozox says:

    > I wonder if it has one for decoding message numbers.

    "wm", last time I checked.

  2. Random832 says:

    Is there a documented API to retrieve the name of a registered window message given the number?

  3. Cool, I didn’t know about the ",hr" trick for viewing error codes.  Thanks for the link!  There’s also the ",(number)" trick for viewing pointers as arrays of size (number).

    Any other ",(something)" strings you can append to a variable in the debugger to get a better data view?

  4. Lukas says:

    Thank you for the list. I am wondering why files like winuser.h do not seem to be available (for viewing) on MSDN, as I think lots of programmers (often without access to the SDK – and their headers) need access to these definitions..

  5. Erik says:

    Adam, see http://msdn.microsoft.com/75w45ekt for the full list.

  6. someone else says:

    Windows development without the SDK? Sounds adventurous.

  7. Ben Voigt [C++ MVP] says:

    @someone else:

    For e.g. a VB6 programmer, whose tools can’t process winuser.h anyway… I can see why such might not bother with the SDK.

    Of course, just posting the headers doesn’t really help much, you have to know which header defines a constant and using "Goto Definition" in Visual Studio (with a C++ project active) is the fastest way I know of.

  8. Neil says:

    At least up to Windows XP, RegisterWindowMessage(W) actually has the same address as RegisterClipboardFormat(W). So you can call GetClipboardFormatName(W) to find out the name of a registered window message.

  9. Lukas says:

    @someone else:

    VB6, or just C#/VB.net (for example when placing keyboard/mouse hooks)..

  10. Random832 says:

    @Neil, I already know the undocumented API for it, I was asking if there’s a documented one.

  11. Yuri Khan says:

    I have a couple of batch files that do the grepping for me:

    :: errorlook.cmd

    @c:bingrep.exe -i -B 7 -h %1 "C:Program FilesMicrosoft SDKsWindowsv6.0AIncludeWinError.h" "C:Program FilesMicrosoft SDKsWindowsv6.0AIncludevfwmsgs.h"

    :: uuidlook.cmd

    @c:bingrep.exe -i -A 2 -h %1 "C:Program FilesMicrosoft SDKsWindowsv6.0AIncludeuuids.h"

    As a nice side effect, these allow me to search both by key (error code and UUID respectively) and by text. The –before-context and –after-context values are hand-tuned for the files being grepped.

Comments are closed.

Skip to main content