Jump to content
  • Advertisement
Sign in to follow this  
billconan

[.net] how to disable the default shortcut keys?

This topic is 4882 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi guys, i want to impart the key 'Alt' some specific function, but every time it was pressed the menu would be actived automatically, cause it is the default shortcut key for accessing the menu. so is there any way that i can disable the default shortcut? thank you! sorry for my poor english.

Share this post


Link to post
Share on other sites
Advertisement
hey there, i think the "check this out" is great, but it's in c++. i just can't get it. and what's PInvoke?

many thanks!

Share this post


Link to post
Share on other sites
PInvoke is a way of referencing 'ordinary' dll's and invoking their methods.
PInvoke article
For exellent help with PInvoke see this
It has a great plugin for VS and a lot of help.
For the method SetWindodsHookEx see this

Cheers

Share this post


Link to post
Share on other sites
You don't need to call anything externally. Just override ProcessCmdKey from the form.

I have something where I want Alt + mouse button to do something without focusing the menu bar, but at the same time I wanted to be able to hit "Alt-F" to jump to "File" in the menu. So what I did was strip the Alt and Menu modifier from the keyData unless a letter was pressed too. KeyDown, KeyUp, KeyPress will work as normal.

protected override bool ProcessCmdKey(ref Message msg,Keys keyData)
{
//This is a bit ugly for stripping out the modifiers but it works.
int num=((int)keyData)&0xFF;
if(num<(int)Keys.A || num>(int)Keys.Z)
{keyData=keyData&(~Keys.Menu)&(~Keys.Alt);}

return base.ProcessCmdKey(ref msg,keyData);
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!