WM_APPCOMMAND and blocking events from active window

TheHaley
TheHaley used Ask the Experts™
on
I'm trying to prevent a WM_APPCOMMND message from reaching the active window.

Using SetWindowsHookEX with WH_CALLWNDPROC I'm able to SEE the message, but I can't remove or modify the message. Using another hook with WH_GETMESSAGE, I can't see the WM_AppCommand Message. Using SPY++, the AppCommand message (0x319) shows up as Unknown. Does that matter?

Since the AppCommand keys I'm blocking all are related to explorer, if I don't have explorer as my active widow, I'm able to block them - I use a hook with WH_SHELL. If the ncode I intercept HSHELL_APPCOMMAND, I just don't call the next hook and the button press is ignored.

However if Explorer is active, it catches the message first. How do I block the message if the only time I can see the message is in context that I can't modify.

(Or how do I see the message with WH_GETMESSAGE -(and then what do I do to keep it from reaching the window?)

I even tried remove the focus from explorer when I caugh an AppCommand with WH_CALLWNDPROC - It works for every key press after the intial one, but the first message is still handled.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
what u need is not hooking, try to use subclassing, when using subclassing u can choose to pass the same message or to pass a different message or simply take no action at all!

Author

Commented:
I'm investigating subclassing now. I've never used it before. Would I need to sublclass every window or just the acitve one? How should I go about it? set up a hook and subclass a window when it becomes active and release it when its no longer active?

Author

Commented:
thank you! Subclassing, after some trial and error, enabled me to intercept and ignore the message.

I gave you full points because your answer helped me to solve my problem. I rated the answer as a B since, while VERY helpful, it wasn't the complete solution. I needed more information (especialy relating to when and what to subclass)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial