Discussion:
WH_GETMESSAGE & WH_MSGFILTER hook and sysmenu
(too old to reply)
mr.sir bossman
2006-10-27 11:12:02 UTC
Permalink
I have the following hooks installed and I want to stop the sysmenu from
appearing when you press the alt key and then up/down arrow key. What would
be the best way to do this?

Any help greatly welcomed.

//WH_GETMESSAGE &&WH_MSGFILTER
LRESULT CALLBACK MemberGetMsgProc(int code, WPARAM wp, LPARAM lp)
{
if (code < 0) // do not process message
return CallNextHookEx(m_hgetmsg, code, wp, lp);

if(code == HC_ACTION)
{
MSG *Msg = reinterpret_cast<MSG *>(lp);

//TB_SETHOTITEM a toolbar item
if(Msg->message == WM_SYSKEYUP && Msg->wParam == VK_MENU)
SendMessage(Msg->message, Msg->wParam, Msg->lParam);

}
return CallNextHookEx(m_hgetmsg, code, wp, lp);
}


LRESULT CALLBACK MemberMsgFilterProc(int code, WPARAM wp, LPARAM lp)
{

if (code < 0) // do not process message
return CallNextHookEx(m_hmsgfilter, code, wp, lp);

if(code == MSGF_MENU)
{
MSG *Msg = reinterpret_cast<MSG *>(lp);
if(Msg->message == WM_MOUSEMOVE)
::SendMessage(m_hWnd, WM_MOUSEMOVE, wp, (LPARAM)&Msg->pt);
}

return CallNextHookEx(m_hmsgfilter, code, wp, lp);
}
mr.sir bossman
2006-10-27 17:12:02 UTC
Permalink
alt key(VK_MENU) + postmessage(WM_keydown, VK_ESC) + arrow key(VK_DOWN) = No
SysMenu. So is my problem due to gained/lost focus of windows in my app? What
do I do?
Tim Roberts
2006-10-28 06:28:57 UTC
Permalink
Post by mr.sir bossman
alt key(VK_MENU) + postmessage(WM_keydown, VK_ESC) + arrow key(VK_DOWN) = No
SysMenu. So is my problem due to gained/lost focus of windows in my app? What
do I do?
I have no idea what you are asking here. What is the problem?
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
mr.sir bossman
2006-10-28 10:30:01 UTC
Permalink
Post by Tim Roberts
I have no idea what you are asking here. What is the problem?
I want to stop the default action of alt + down/up arrow = Sysmenu. While
not disabling alt + space key = Sysmenu.
Tim Roberts
2006-10-29 20:32:16 UTC
Permalink
Post by mr.sir bossman
Post by Tim Roberts
I have no idea what you are asking here. What is the problem?
I want to stop the default action of alt + down/up arrow = Sysmenu. While
not disabling alt + space key = Sysmenu.
That's tricky. Remember that these are two different sequences; for
Alt-Space, the Alt key must be held down. For up/down arrow, you have to
press Alt, then release Alt, then press Down. That means someone is
storing up state somewhere.

The Alt/Down sequence sends WM_SYSMENU. You can try trapping that and
blocking it unless the Alt key is currently being held down.

What about the Windows menu key? Are you going to block that as well? F10
also brings up the menu. Are you going to block that?
--
Tim Roberts, ***@probo.com
Providenza & Boekelheide, Inc.
mr.sir bossman
2006-10-31 11:35:02 UTC
Permalink
I didn't realize(spoiled by wtl) that when you don't have a menu when you
press the alt key it highlights the titlebar.

I Just need to change focus...I guess.
Post by Tim Roberts
Post by mr.sir bossman
Post by Tim Roberts
I have no idea what you are asking here. What is the problem?
I want to stop the default action of alt + down/up arrow = Sysmenu. While
not disabling alt + space key = Sysmenu.
That's tricky. Remember that these are two different sequences; for
Alt-Space, the Alt key must be held down. For up/down arrow, you have to
press Alt, then release Alt, then press Down. That means someone is
storing up state somewhere.
The Alt/Down sequence sends WM_SYSMENU. You can try trapping that and
blocking it unless the Alt key is currently being held down.
What about the Windows menu key? Are you going to block that as well? F10
also brings up the menu. Are you going to block that?
--
Providenza & Boekelheide, Inc.
Loading...