473,385 Members | 1,342 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 4130
Plater
7,872 Expert 4TB
Why not just always do base.ProcessCmdKey(ref message, keys); ?
Nov 10 '09 #2

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

Similar topics

25
by: Steve Jorgensen | last post by:
Yup, Steve's full of tips, but hey, it makes him feel important, right? Ok, here goes. I've been trying to improve encapsulation by putting code in the same object as the stuff it affects, so I...
13
by: Stuart McGraw | last post by:
I haven't been able to figure this out and would appreciate some help... I have two tables, both with autonumber primary keys, and linked in a conventional master-child relationship. I've...
4
by: Ralf Toender | last post by:
Hi! Does anybody know how to send a keystroke C#? In C++ it's done by: keybd_event ( ... ) or SendInput ( ... ). What namespace does include this counterpart? Thanks Ralf
1
by: Raed Sawalha | last post by:
I have Solution with multiple project as following hierarchy Parent Child Child Child the parent is the ONLY one has the Global.ascx , now im in case i need to access the global.ascx public...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
0
by: TCook | last post by:
Hello All, First, I apologize for posting this to so many newsgroups but I wasn't sure which newsgroup was most appropriate nor which newsgroup would most likely have subscribers that have done...
4
by: raj_genius | last post by:
I hav two queries, whc are as follows: FIRSTLY: is it possible to access the controls(by name) of a parent form(MDI) from its child forms??if yes then how??plzz provide a coded example in VB if...
4
by: Richard Lewis Haggard | last post by:
What is the mechanism by which a child window can notify its parent that it has been clicked on? -- Richard Lewis Haggard www.Haggard-And-Associates.com
8
by: BD | last post by:
How can I duplicate the behavior of the operating system shortcut keys in my application? For example, my windows form has 5 controls (textboxes), the operating system will pickup which control...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.