Posts: 81
Threads: 37
Joined: Jun 2008
I'd like to be able to process messages from WindowProc function
http://msdn.microsoft.com/en-us/library/...85%29.aspx, so I tried to piece together a function based on the AltMouseTriggers sample (which uses LowLevelMouseProc function). But it doesn't work. Any suggestions?
Function WinProcMessages
function [nCode] [wParam] [CWPSTRUCT*m]
if(getopt(nargs)=0)
int+ g_whook=SetWindowsHookEx(WH_CALLWNDPROC &WinProcMessages _hinst GetCurrentThreadId)
opt waitmsg 1
wait -1 -V g_whook
ret
sel m.message
case WM_LBUTTONDBLCLK
out "double"
case WM_MOVE
out "move"
case WM_SIZE
out "size"
ret CallNextHookEx(g_whook nCode wParam m)
Posts: 12,073
Threads: 140
Joined: Dec 2002
it works. To test, I replaced wait to mes. It shows these messages received by the message box.
Function
WinProcMessages
function [nCode] [wParam] [CWPSTRUCT*m]
if(getopt(nargs)=0)
,int+ g_whook=SetWindowsHookEx(WH_CALLWNDPROC &WinProcMessages _hinst GetCurrentThreadId)
,;opt waitmsg 1
,;wait -1 -V g_whook
,mes 1
,ret
sel m.message
,case WM_LBUTTONDBLCLK
,out "double"
,case WM_MOVE
,out "move"
;;;
,case WM_SIZE
,out "size"
ret CallNextHookEx(g_whook nCode wParam m)
I tested on Vista. If does not work, try to replace _hinst to 0.
Posts: 81
Threads: 37
Joined: Jun 2008
Yes, some of the messages are processed but not the mouse messages for some reason.
Function
WinProcMessages
function [nCode] [wParam] [CWPSTRUCT*m]
if(getopt(nargs)=0)
,int+ g_whook=SetWindowsHookEx(WH_CALLWNDPROC &WinProcMessages 0 GetCurrentThreadId)
,mes 1
,if(!ShowDialog("diggy" 0)) ret
,ret
sel m.message
,case WM_NCLBUTTONDOWN
,out "WM_NCLBUTTONDOWN"
,case WM_LBUTTONDOWN
,out "WM_LBUTTONDOWN"
,case WM_NCHITTEST
,out "WM_NCHITTEST"
,if(m.lParam=HTBOTTOM)
,,out "HTBOTTOM"
,if(m.lParam=HTZOOM)
,,out "HTZOOM"
ret CallNextHookEx(g_whook nCode wParam m)
I'd like to get the WM_NCHITTEST messages for any active window. The code below seems to work better for this purpose, but is there a more efficient way?
rep
,0.1
,POINT p; xm(p)
,int ht=SendMessage(win WM_NCHITTEST 0 (p.x&0xffff)|(p.y<<16))
,sel ht
,,case HTBOTTOM out "HTBOTTOM"
,,case HTCAPTION out "HTCAPTION"
Posts: 12,073
Threads: 140
Joined: Dec 2002
Mouse messages are posted (PostMessage), not sent (SendMessage). You need another type of hook (WH_...).
----
Don' know a better way than WM_NCHITTEST.