Home All Groups Group Topic Archive Search About

Processing KeyDown in MDI Parent

Author
12 May 2005 1:56 PM
Chris Lieb
Is there a way to catch a KeyDown event in a MDI parent form?  I have a
special admin login prompt that only appears when you press Ctrl+Shift+A, but
currently I have to open one of the children forms first before I can catch
this key stroke.  I do not want this option to be obvious to the end users
since I hard-coded that password since I know of no secure way to store it
otherwise and not have it get changed from one workstation to another. 
Thanks.

--
Chris Lieb
UPS CACH, Hodgekins, IL
Tech Support Group - Systems/Apps

Author
14 May 2005 9:00 PM
Bonj
When a key is pressed, as long as the Alt key is not being pressed, the
WM_KEYDOWN message will be sent to the window that has the focus. When there
are no children, this might be the MDI client window, or it may be another
window in your application, e.g. a sibling of the MDI client window. Use
Spy++ to spy on the main (top level) window of your application, check
'windows of same process' and clear all messages but WM_KEYDOWN, then do
your keystroke - then in the message log right click on the message to find
out which window it got sent to. I'm not sure whether the MDI client window
even can receive focus but if it can and does, then you might have to
subclass it to receive the message.
If the MDI client window has siblings (e.g. treeview), then you can't be
sure it won't be one of the siblings that receives the keystroke message.

Show quote
"Chris Lieb" <ChrisL***@discussions.microsoft.com> wrote in message
news:1C419328-42C8-462C-9AFF-60DBAAC801F3@microsoft.com...
> Is there a way to catch a KeyDown event in a MDI parent form?  I have a
> special admin login prompt that only appears when you press Ctrl+Shift+A,
> but
> currently I have to open one of the children forms first before I can
> catch
> this key stroke.  I do not want this option to be obvious to the end users
> since I hard-coded that password since I know of no secure way to store it
> otherwise and not have it get changed from one workstation to another.
> Thanks.
>
> --
> Chris Lieb
> UPS CACH, Hodgekins, IL
> Tech Support Group - Systems/Apps

AddThis Social Bookmark Button