Author Topic: Monitoring WM_nnnn messages  (Read 1559 times)

jj2007

  • Member
  • *****
  • Posts: 7641
  • Assembler is fun ;-)
    • MasmBasic
Monitoring WM_nnnn messages
« 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
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)


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 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

dedndave

  • Member
  • *****
  • Posts: 8741
  • Still using Abacus 2.0
    • DednDave
Re: Monitoring WM_nnnn messages
« Reply #1 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