\$25

### Image of the Day Submit

IOTD | Top Screenshots

## disable default system 'left alt' key behaviour in a window

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

8 replies to this topic

### #1Alessio1989  Members

Posted 04 November 2013 - 06:03 PM

Hi,

is there a way to disable the "system behaviour" of the 'left alt' key in a window?

Please note that I don't wanna completely disable it, I only need to disable the "special" system behaviour.

"Recursion is the first step towards madness." - "Skeggǫld, Skálmǫld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/

Posted 04 November 2013 - 06:05 PM

POPULAR

Are you handling WM_SYSKEYDOWN messages?

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646286%28v=vs.85%29.aspx

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

### #3Alessio1989  Members

Posted 04 November 2013 - 06:48 PM

thank you, it worked. Now I have to disable the alt-space combo for the app-menu but a simple style-change should works.

"Recursion is the first step towards madness." - "Skeggǫld, Skálmǫld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/

### #4Alessio1989  Members

Posted 04 November 2013 - 08:09 PM

thank you, it worked. Now I have to disable the alt-space combo for the app-menu but a simple style-change should works.

Ok, this works for a single click/action of the left-alt key:

case WM_SYSKEYDOWN:
if( wParam == VK_MENU )// left-alt key
{
foo();
}
break;


but if the left-alt key is not released, the key still behave as a system command...

"Recursion is the first step towards madness." - "Skeggǫld, Skálmǫld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/

Posted 04 November 2013 - 08:14 PM

You should get another WM_SYSKYDOWN message with bit 29 set to 1 in the lParam in that case?

Bits Meaning 29 The context code. The value is 1 if the ALT key is down while the key is pressed; it is 0 if the WM_SYSKEYDOWN message is posted to the active window because no window has the keyboard focus.

Edited by Paradigm Shifter, 04 November 2013 - 08:15 PM.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

### #6Alessio1989  Members

Posted 04 November 2013 - 08:43 PM

You should get another WM_SYSKYDOWN message with bit 29 set to 1 in the lParam in that case?

Bits Meaning 29 The context code. The value is 1 if the ALT key is down while the key is pressed; it is 0 if the WM_SYSKEYDOWN message is posted to the active window because no window has the keyboard focus.



default:
lParam |= 1 << 29;
return( DefWindowProc( window, message, wParam, lParam ) );


in this way I can disable the application system menu, but the left-alt key still behaves as a "system key" (ie: if left-alt key is still pressed, message case like WM_KEYDOWN are not processed and the windows "ding" sounds .-. )

What I want is disable this "special system behaviour"  to the left alt key, but maybe that's not a good idea... :s

Edited by Alessio1989, 04 November 2013 - 08:43 PM.

"Recursion is the first step towards madness." - "Skeggǫld, Skálmǫld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/

Posted 04 November 2013 - 08:56 PM

I don't get why you are modifying lParam?

If you don't want the default behaviour, return the appropriate value from your window procedure to say you handled it, and DO NOT call DefWindowProc if you handle the message yourself.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

### #8Alessio1989  Members

Posted 04 November 2013 - 09:08 PM

sorry, it's late  here ( 03:43 AM.).. maybe I should go to sleep...

so this is what I have:



case WM_SYSKEYDOWN:
if( wParam == VK_MENU || wParam == VK_F10 )// left-alt and f10 keys
{
foo();
}
break;


this works fine with F10: the application process other case-action (like WM_KEYs messages) even if the F10 key is not released. That's not happens if the left ALT key is not released: I got the annoying windows "ding" sound and other things associated to other message cases don't happen.

Thank you for your patience

Edited by Alessio1989, 04 November 2013 - 09:09 PM.

"Recursion is the first step towards madness." - "Skeggǫld, Skálmǫld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/

### #9Alessio1989  Members

Posted 05 November 2013 - 05:22 AM

never mind, I will redefine the alt-key with a custom LowLevelKeyboardProc, Windows could be such a bitch...

"Recursion is the first step towards madness." - "Skeggǫld, Skálmǫld, Skildir ro Klofnir!"
Direct3D 12 quick reference: https://github.com/alessiot89/D3D12QuickRef/

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.