Sign in to follow this  
Alessio1989

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

Recommended Posts

Alessio1989    4634

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.

Share this post


Link to post
Share on other sites
Alessio1989    4634

 

 

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...

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites
Alessio1989    4634

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Alessio1989    4634

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 unsure.png

Edited by Alessio1989

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this