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

Re: GETMESSAGE hook, WM_SYSCOMMAND, SC_CLOSE, and the "X" button? by Igor

Igor
Sun Jul 22 14:36:44 CDT 2007

"Vincent Fatica" <vince@blackholespam.net> wrote in message
news:46a399b4$1@news.vefatica.net
> 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



Re: GETMESSAGE hook, WM_SYSCOMMAND, SC_CLOSE, and the "X" button? by Vincent

Vincent
Sun Jul 22 16:57:26 CDT 2007

On Sun, 22 Jul 2007 15:36:44 -0400, "Igor Tandetnik" <itandetnik@mvps.org>
wrote:

>"Vincent Fatica" <vince@blackholespam.net> wrote in message
>news:46a399b4$1@news.vefatica.net
>> 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?

No I wasn't. Thanks. I tried it. It didn't help.
--
- Vince