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

You can define a "base" Form with your ProcessCmdKey handler implemented, and then make all your other Forms : the MDI Parent, the Child Windows of the MDI Parent, and any "Independent" Forms you create (i.e. , not children of the MDI Form) inherit from the "base Form. " Just make sure the IsMdiContainer property is set on the form you wish to be MDI, and the child windows you add to the MDI Form are not TopLevel and have their parent set to the MDI Form.

You can define a "base" Form with your ProcessCmdKey handler implemented, and then make all your other Forms : the MDI Parent, the Child Windows of the MDI Parent, and any "Independent" Forms you create (i.e. , not children of the MDI Form) inherit from the "base Form. " Just make sure the IsMdiContainer property is set on the form you wish to be MDI, and the child windows you add to the MDI Form are not TopLevel and have their parent set to the MDI Form.

The question is, then, where do you want to handle the events triggered by the key combinations you've enabled because ... if you define methods to be triggered by the trapped key combinations in the base Form ... each Form that inherits from the base Form is going to execute them in their own context. If you want to handle the trapped key-combinations on an application wide basis, then implement a static public class with the key-combination handlers defined as static methods there. Or, since you may want to know from which form the special key-combinations issued just pass a pointer to calling Form to the static handler.So, your handler for the control + Tab in the ProcessCmdKey override in the base Form might look like this : // in ProcessCmdKey override in base Form case Keys.

Control | Keys. Tab: KeyHandler. NextTabHandler(this); return true; Your static class might look something like this : public static class KeyHandler { public static void NextTabHandler(Form theCallingForm) { Console.

WriteLine("called from : " + theCallingForm. Text + " : ActiveControl : " + theCallingForm.ActiveControl.Name); if (theCallingForm is MDIForm) { // handle Next Tab on MDIForm control } else if (theCallingForm is childForm) { // handle Next Tab on ChildForm control } else { if(theCallingForm is independentForm) { // handle Next Tab on "independent Form" control } } } } As you can see in the code above, you can use the ActiveControl property of the calling Form to know which control on a given type of Form got the key-combination. Of course, if you don't want to handle the key-combinations "globally," like this, just insert your ProcessCmdKey over-rides as needed in the other Forms, and don't have them inherit from the base Form.

Handling the key events "application wide" may, or may not be the best strategy for your particular solution, but it is a viable strategy.Best.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions