HOWTO: How to Create Accelerators for CPropertyPages (142384)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Editions 2.0
- Microsoft Visual C++, 32-bit Editions 2.1
- Microsoft Visual C++, 32-bit Editions 2.2
- Microsoft Visual C++, 32-bit Editions 4.0
This article was previously published under Q142384 SUMMARY
By default, the only keystrokes that will allow you to navigate between
CPropertyPages in a CPropertySheet are the CTRL+TAB and SHIFT+CTRL+TAB
keys. It may be desirable to have assigned keys that jump you directly to a
particular page. Although the CPropertySheet object doesn't contain this
functionality by default, you can add it by overriding the
CPropertySheet::PreTranslateMessage() function to check for the desired
keystroke.
In the case of ALT key combinations, check for WM_SYSKEYDOWN messages.
OnSysKeyDown cannot be used because the messages will be handled by
::IsDialogMessage before getting to the message handler.
Mnemonics are not possible in versions of the Microsoft Foundation Classes
(MFC) prior to 4.0 because these earlier versions of MFC creates and drew
the tabs using their own techniques. The code uses TextOut() instead of
DrawText() to display text on a tab. TextOut() doesn't interpret the
mnemonic-prefix character (&) as a directive to underscore the character
that follows, so you cannot use this method to designate accelerator keys.
MFC 4.0, which comes with Visual C++ 4.0, uses the Windows 95 Tab control.
This control properly draws mnemonics on the tabs. All you need to do is
add the mnemonic-prefix character (&) to the tab text in the caption field
of your dialog resource.
Modification Type: | Major | Last Reviewed: | 10/17/2003 |
---|
Keywords: | kbcode kbhowto kbNoUpdate KbUIDesign kbVC410fix KB142384 |
---|
|