Windows Develop Bookmark and Share   
 index > ClickOnce and Setup & Deployment Projects > how to make parent form hot keys work in user controls...
 

how to make parent form hot keys work in user controls...

hi,
i have a main form, with a mainmenu, with all the shortcut keys programmed in, Ctrl-s for save etc. which works fine. 

but when the focus is in any user controls, the hotkeys don't work, presumably by design, but in my case, i don't want the users to have to realise that they are in my usercontrol and force them to click out of it to save their document... perhaps a 'Inherit Parent ShortcutKeys' property for System.Windows.Forms.UserControl would be an idea for v1.2?

in the meantime, any work arounds? 
i'm hesitant to do a KeyPress on the usercontrol and switch through every key i want to handle... nasty...

cheers
tim
MigrationUser 1  Tuesday, September 16, 2003 10:40 AM
I have the same problem.


Does anyone have a fix for it?
MigrationUser 1  Wednesday, September 17, 2003 12:17 AM
none of you winforms gurus out there got any work arounds?!

surely MS wouldn't recommend me to get rid of my user controls and have one giant Main Form just so i could get my shortcut keys working from any point in the app...

thanks for any help
tim
MigrationUser 1  Friday, September 19, 2003 4:21 AM
I can't reproduce this . . . Can you tell me a little more about your UserControl?  I created a UserControl with a Textbox on it.  Placed it on a form, focused in the textbox and pressed a shortcut key for the form's main menu and it worked as expected.
MigrationUser 1  Friday, September 19, 2003 11:32 AM
Hi Jacob, 
The problem with my usercontrol (i only realised now) is that it is the HtmlEditor COM wrapper for the IE rich text editing control, the one that supports the ExecCommand interface. i think that means that the text box it uses is not a true Winforms textbox and it wouldn't have any listeners for shortcut keys i presume.  the annoying thing is, people are most likely to hit Ctrl-S with the focus still in that textbox!  

my apologies for implying that MS had made a boo boo. 

i'm just looking in the code for the htmlEditor and it already has a htmlEditor_HtmlKeyPress event, which i can add in a check for a Ctrl-S key press and pass on the event to the mainform. 

cheers
tim
MigrationUser 1  Friday, September 19, 2003 12:10 PM
My next question was going to be if it was an ActiveX/COM control . . .  Glad you were able to find a workaround . . .
MigrationUser 1  Friday, September 19, 2003 12:49 PM

You can use google to search for other answers

Custom Search

More Threads

• Vista Ultimate; Blue screen when publishing clickonce project
• Deploying a WebService in to Rempte Server
• Intermittent Access denied on restart after ClickOnce update
• How to choose the dir to place the program by click once?
• Alternate Task upon Deployment
• ClickOnce downloads all files when a update is available?
• Converting VDPROJ to WIX
• adding another setup to the installer and adding shortcuts to it
• Installing 2 apps in a single setup process
• I need help bad.