Discussion:
GETMESSAGE hook, WM_SYSCOMMAND, SC_CLOSE, and the "X" button?
(too old to reply)
Vincent Fatica
2007-07-22 17:53:56 UTC
Permalink
In an extension (DLL) to a subsystem:windows app I'm trying to make the app hard
to close. A simple WH_GETMESSAGE hook correctly sees <WM_SYSCOMMAND, SC_CLOSE>
when it's generated by the system menu's "Close" (also <Alt-F4>) and translates
it into <WM_SYSCOMMAND, SC_MINIMIZE>. But my hook fails to see <WM_SYSCOMMAND,
SC_CLOSE> when it was generated by the title bar's "X" button. The application
does not set any other hooks.

What's going on here? Can I work around it?

Thanks.
--
- Vince
Igor Tandetnik
2007-07-22 19:36:44 UTC
Permalink
Post by Vincent Fatica
In an extension (DLL) to a subsystem:windows app I'm trying to make
the app hard to close. A simple WH_GETMESSAGE hook correctly sees
<WM_SYSCOMMAND, SC_CLOSE> when it's generated by the system menu's
"Close" (also <Alt-F4>) and translates it into <WM_SYSCOMMAND,
SC_MINIMIZE>. But my hook fails to see <WM_SYSCOMMAND, SC_CLOSE>
when it was generated by the title bar's "X" button. The application
does not set any other hooks.
Have you seen the part of WM_SYSCOMMAND documentation that says:

To obtain the correct result when testing the value of wParam, an
application must combine the value 0xFFF0 with the wParam value by using
the bitwise AND operator.

Are you doing this?
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
Vincent Fatica
2007-07-22 21:57:26 UTC
Permalink
Post by Igor Tandetnik
Post by Vincent Fatica
In an extension (DLL) to a subsystem:windows app I'm trying to make
the app hard to close. A simple WH_GETMESSAGE hook correctly sees
<WM_SYSCOMMAND, SC_CLOSE> when it's generated by the system menu's
"Close" (also <Alt-F4>) and translates it into <WM_SYSCOMMAND,
SC_MINIMIZE>. But my hook fails to see <WM_SYSCOMMAND, SC_CLOSE>
when it was generated by the title bar's "X" button. The application
does not set any other hooks.
To obtain the correct result when testing the value of wParam, an
application must combine the value 0xFFF0 with the wParam value by using
the bitwise AND operator.
Are you doing this?
No I wasn't. Thanks. I tried it. It didn't help.
--
- Vince
Loading...