The MASM Forum

General => The Workshop => Topic started by: jj2007 on October 16, 2013, 09:08:36 AM

Title: Monitoring WM_nnnn messages
Post by: jj2007 on October 16, 2013, 09:08:36 AM
A simple way to monitor which messages are being sent by Windows, with only two minor changes to the source, here applied to \masm32\examples\exampl01\generic\generic.asm:
if 1
    include \masm32\MasmBasic\MasmBasic.inc        ; download version 16 October 2013 (http://masm32.com/board/index.php?topic=94.0)
else
...
    includelib \masm32\lib\kernel32.lib  ; line 34
endif


Line 200ff:
WndProc proc hWin   :DWORD,
             uMsg   :DWORD,
             wParam :DWORD,
             lParam :DWORD
  inc msgCount
  deb 4, "msg", chg:msgCount
        ; msg will only be shown if msgCount has changed (more on deb (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1019))


Output:
msg     chg:msgCount    1       uMsg = Start monitoring
msg     chg:msgCount    2       uMsg = WM_GETMINMAXINFO
msg     chg:msgCount    3       uMsg = WM_NCCREATE
msg     chg:msgCount    4       uMsg = WM_NCCALCSIZE
msg     chg:msgCount    5       uMsg = WM_CREATE
msg     chg:msgCount    6       uMsg = WM_WINDOWPOSCHANGING
msg     chg:msgCount    7       uMsg = WM_NCCALCSIZE
msg     chg:msgCount    8       uMsg = WM_WINDOWPOSCHANGED
msg     chg:msgCount    9       uMsg = WM_MOVE
msg     chg:msgCount    10      uMsg = WM_SIZE
msg     chg:msgCount    11      uMsg = WM_SHOWWINDOW
...
msg     chg:msgCount    200      uMsg = WM_DESTROY


Source and executable attached. MasmBasic version 16 October (http://masm32.com/board/index.php?topic=94.0) is required to run the executable.

P.S.: You can configure which messages are not shown. By default, WM_MOUSEMOVE, WM_NCHITTEST, WM_SETCURSOR, WM_GETICON and WM_NCMOUSEMOVE are excluded, but if, for example, you want to monitor the menu IDs and don't want to see a Million WM_ENTERIDLE messages, just add them to the exclude equate:

  NoDebMsg CATSTR NoDebMsg, <, WM_ENTERIDLE>   ; don't show this message
  movzx ecx, word ptr wParam
  deb 4, "msg", chg:ecx   ; shows the message if loword of wParam has changed
Title: Re: Monitoring WM_nnnn messages
Post by: dedndave on October 16, 2013, 10:42:20 AM
it's ineresting to watch the messages
i found it quite educational to create 2 windows (processes, actually)
one to display the messages received in the other, much like what you have done

(http://img577.imageshack.us/img577/943/9c3g.png)