Search code examples
c#winformswndprocwm-syscommand

WM_SYSCOMMAND with wParam 0xF063?


I am trapping WM_SYSCOMMAND messages in WinForm in a C# application for reasons that are not relevant. Sometimes, my handler receives a WM_SYSCOMMAND message with the wParam 0xF063.

There is no 0xF063 in the documentation

Passing it to the base Form class's WndProc seems to close the window, which I suppose makes sort-of sense as the wParam is almost 0xF060 (the SC_CLOSE message).

So... what exactly is this 0xF063 message, and what distinguishes it from the normal SC_CLOSE? Why even have it if it seems to do the exact same thing as SC_CLOSE? There seems to be no documentation regarding this value.


Solution

  • Yes, it is the SC_CLOSE command. From the MSDN article for WM_SYSCOMMAND:

    In WM_SYSCOMMAND messages, the four low-order bits of the wParam parameter are used internally by the system. To obtain the correct result when testing the value of wParam, an application must combine the value 0xFFF0 with the wParam value by using the bitwise AND operator.