diz
June 11th, 2004, 08:54
I would like to not allow some message (WM_CLOSE) to be received by some application. I mean, when I click on X in top right corner, I want the app to do nothing.
I though that it would be easy. I tried to set up a hook in to message queue. I used Iczelion tutorial and modified his sample a little:
But it does not react on WM_CLOSE. Messagebox never popups, whenever I close some other application or app that sets the hook.
I also not sure, when (and do) I need to call CallNextHookEx function. It seems to make no difference.
What am I doing wrong? Maybe it's not possible to prevent app from receiving message?
I though that it would be easy. I tried to set up a hook in to message queue. I used Iczelion tutorial and modified his sample a little:
Code:
GetMsgProc proc nCodeWORD,wParam
WORD,lParam
WORD
; invoke CallNextHookEx,hHook,nCode,wParam,lParam
mov edx,lParam
assume edx:PTR MSG
.if [edx].message==WM_CLOSE
invoke MessageBox,NULL,offset caption,offset caption,MB_OK
.endif
assume edx:nothing
xor eax,eax
ret
GetMsgProc endp
InstallHook proc hwndWORD
push hwnd
pop hWnd
invoke SetWindowsHookEx,WH_GETMESSAGE,addr GetMsgProc,hInstance,NULL
mov hHook,eax
ret
InstallHook endp
But it does not react on WM_CLOSE. Messagebox never popups, whenever I close some other application or app that sets the hook.
I also not sure, when (and do) I need to call CallNextHookEx function. It seems to make no difference.
What am I doing wrong? Maybe it's not possible to prevent app from receiving message?