Getting ALT+F11 in Windows Forms

There is no real mystery to this, but I spent a few cycles on it and maybe it will help someone else. When I first implemented this, I didn't set KeyPreview to true and I never received the KeyDown event.

.
.
m_form.KeyPreview = true
;
m_form.KeyDown +=
new System.Windows.Forms.KeyEventHandler
(m_form_KeyDown);
.
.

 

// Handle Alt+F11
void m_form_KeyDown(object sender, System.Windows.Forms.KeyEventArgs
e)
{
   
if ((e.Modifiers == System.Windows.Forms.Keys.Alt) && (e.KeyCode == System.Windows.Forms.Keys
.F11))
   {
         BringUpIDE();
         e.Handled =
true
;
   }

}


Posted Jul 18 2007, 11:47 AM by rszografos

Comments

Melody wrote re: Getting ALT+F11 in Windows Forms
on 07-20-2007 10:08 AM

It is also possible to associate the shortcut by selecting the control in Design view and setting the ShortcutKeys property under the misc section.

Copyright Summit Software Company, 2008. All rights reserved.