|
-
May 25th, 1999, 06:15 AM
#1
Keyboard ShortCut
Hi All,
I have developed a Dialog Based Application. I have a few buttons on the dialog box. I want to add Keyboard shortcuts so that the user can use the keyboard also(Right now only mouse can be used).
Can any one tell me how to add keyboard shortcuts like (Alt+S or Ctrl+S etc).
Thanks in Advance
Vittal
-
May 25th, 1999, 06:19 AM
#2
Re: Keyboard ShortCut
To put in Hotkeys, use the "&" e.g. for a button with Help, put in H&elp and then the "e" will be the hotkey (underscored)
-
May 25th, 1999, 01:10 PM
#3
Re: Keyboard ShortCut
No, that's how you create accelerators.
To use hot keys, do one of the following:
1 Use a CHotKeyCtrl in your app's window
2 Use ::RegisterHotKey, ::UnregisterHotKey
/ravi
-
May 26th, 1999, 12:41 AM
#4
Re: Keyboard ShortCut
Actually with a little work you can use a real accelerator table in your dialog. Follow these steps...
1) Create a member variable in your dialog class like this
HACCEL m_hAccel;
2) Initialize the variable in the dialogs constructor, and load the accelerator into the dialog like so
m_hAccel=::LoadAccelerators(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDR_ACCELERATOR1));
3) Overload the PreTranslateMessage handler in the dialog like so
BOOL CYourtDlg::PreTranslateMessage(MSG* pMsg)
{
if (m_hAccel != NULL)
if(::TranslateAccelerator(m_hWnd, m_hAccel, pMsg))
return TRUE;
return CDialog::PreTranslateMessage(pMsg);
}
Thats all there is to it!!!
-
May 29th, 1999, 12:49 PM
#5
Re: Keyboard ShortCut
I have been following this thread... Can you give a sample of the use of RegisterHotKey?
Thanks.
Larry Woods
l.woods, inc.
Scottsdale, Arizona
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|