PRB: TAB Behavior When Using MFC Subclassed Control on VB Form (214476)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q214476 SYMPTOMS
You are working with a Microsoft Foundation Classes (MFC) control based on or subclassed from another control, for example, a combo box.
You place the MFC control and other controls on a Visual Basic form and run the project. When you click the composite control on the MFC control and press the TAB key, the focus does not change.
CAUSE
To tab from control to control, the TAB key must be processed by the container. This only occurs when the control is In Place Activated. When you click the combo box on the MFC control, the composite control receives the focus, but the entire MFC control is not In Place Activated.
RESOLUTION
Use the following in both the OnCreate function and the OnMouseActivate function to In Place Activate the control:
OnActivateInPlace (TRUE, NULL);
Note that after these changes have been made, other accelerator keys, like the arrow keys, will also be processed by the container when the MFC control receives the focus. However, you may want your control to process these keys. To solve this problem, you need to intercept the messages in the control's PreTranslateMessage function. This is described in the following Microsoft Knowledge Base article: Q168777 PRB: MFC ActiveX Control in IE Doesn't Detect Keystrokes
The last remaining issue is that when you tab through the controls on the form, the cursor is not on your MFC control when it receives the focus. You must set the focus to the composite control. REFERENCES
For additional information about focus issues with MFC controls, please see the following article in the Microsoft Knowledge Base: 168777 PRB: MFC ActiveX Control in IE Doesn't Detect Keystrokes
Modification Type: | Major | Last Reviewed: | 5/13/2003 |
---|
Keywords: | kbCtrlCreate kbprb KB214476 |
---|
|