Capturing KeyDown Event in MDI App

grip003

Regular
Joined
Sep 2, 2004
Messages
89
Location
North Carolina
I am trying to capture the CAPS and NUMLOCK keys in an MDI application. I have set the KeyPreview to true and coded the KeyDown event. The problem occurs when a dialog form is being shown. The KeyPreview does not seem to fire when using a dialog form (using ShowDialog()). Is there a way around this without having to add code to every form that is brought up as a dialog form?
 
Just off the top of my head, and maybe someone has a better idea, I would make a class with a method that holds the code you want in your KeyDown event. Just call that method from the KeyDown handler on each of the dialogs rather than repeating the whole code.
 
Back
Top