PRB: Focus and Tab Issues with ATL Subclassed Edit Control (179696)
The information in this article applies to:
- The Microsoft Active Template Library (ATL) 2.0, when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- The Microsoft Active Template Library (ATL) 2.1, when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
This article was previously published under Q179696 SYMPTOMS
If you use the ATL Wizards to create an ActiveX control that subclasses the
Edit common control, you may see one or both of the following problems
depending on where you use the control:
- You cannot use the TAB key to set focus to the ActiveX Edit control. You must use the mouse to set focus and activate the ActiveX Edit control.
- Once the ActiveX Edit control has the focus, you will hear a beep if you try to use the TAB key to change the focus away from it.
CAUSE
When an ATL-based ActiveX control subclasses a Windows common control, it
creates a contained window object to subclass the control. When you use the
TAB key to move around an application, the ActiveX control window gets the
focus but never shifts the focus to the Edit window within the ActiveX
control. As a result, you must click the Edit control to activate it.
The second issue results from the way an ATL-based control and its ActiveX
control container handle messages. Because of the way some control
containers handle messages, they do not get the opportunity to process the
TAB keystroke, even if the control itself does not process it.
RESOLUTION
To activate the ATL-based ActiveX Edit control with the TAB key, you can
override the OnSetFocus method and set the focus to the contained Edit
window before returning.
To use the TAB key to shift the focus away from the ATL-based control, you
can override the TranslateAccelerator method. If the message is WM_KEYDOWN
and the key is the TAB key, give the IOleControlSite TranslateAccelerator a
chance to process the message first.
STATUS
This problem was corrected in Visual C++ version 6.0 for Windows.
REFERENCES
(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Shawn
William Karr, Microsoft Corporation
Modification Type: | Major | Last Reviewed: | 12/8/2003 |
---|
Keywords: | kbAcceleratorKey kbCtrlCreate kbEditCtrl kbKeyAccel kbprb KB179696 |
---|
|