An easy way would be to just grab the mouse. When you have a captured mouse, you get one event per click outside of your window, and then it is removed.
A more sophisticated way would be to hook a low-level window hook. To make a global hook, you have to put your hook code in an unmanaged DLL.
A very simple way is to simply close the form when it is deactivated.
EDIT
Unfortunately. I just realized that I did not answer your direct question about message identifiers. Message 0x118 is not defined in winuser.h, so I assume this is an undocumented message identifier. Message identifiers ranging from 0xC000 to 0xFFFF are messages defined by the application. These identifiers are returned by RegisterWindowMessage .
source share