469,337 Members | 5,988 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,337 developers. It's quick & easy.

Try to implement global keyboard shortcut in MDI parent/child form and other form by

I override ProcessCmdKey() in my MDI parent form class and have some keyboard shortcut calling method in same class. But I wish to make these hotkeys working in parent/child form and other form. The case now is when focus on the other form(regular form, not MDI), ProcessCmdKey() doesn't capture keyboard anymore. Which class should I put ProcessCmdKey() in and anything to make it work? Thanks!
Expand|Select|Wrap|Line Numbers
  1. namespace myNamespace
  2. {
  3.     public class MDIParent : System.Windows.Forms.Form
  4.     {
  5.  
  6.         public bool NextTab(){...}
  7.         public bool PreviousTab(){...}
  8.  
  9.         protected override bool ProcessCmdKey(ref Message message, Keys keys)
  10.         {
  11.             switch (keys)
  12.             {
  13.                 case Keys.Control | Keys.Tab:
  14.                     NextTab();
  15.                     return true;
  16.  
  17.                 case Keys.Control | Keys.Shift | Keys.Tab:
  18.                     PreviousTab();
  19.                     return true;
  20.             }
  21.             return base.ProcessCmdKey(ref message, keys);
  22.         }
  23.     }
  24.  
  25.     public class mySecondForm : System.Windows.Forms.Form
  26.     {
  27.         ...
  28.     }
  29. }
Nov 10 '09 #1
1 3767
Plater
7,872 Expert 4TB
Why not just always do base.ProcessCmdKey(ref message, keys); ?
Nov 10 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Ralf Toender | last post: by
1 post views Thread by Raed Sawalha | last post: by
4 posts views Thread by Richard Lewis Haggard | last post: by
8 posts views Thread by BD | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by Marylou17 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.