Article ID: 187644
Article Last Modified on 6/4/2005
APPLIES TO
- Microsoft ActiveX Template Library 2.0, when used with:
- Microsoft Visual C++ 5.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 5.0 Professional Edition
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual C++ 6.0 Standard Edition
- Microsoft Visual C++ .NET 2002 Standard Edition
- Microsoft Visual C++ .NET 2003 Standard Edition
- Microsoft ActiveX Template Library 2.1, when used with:
- Microsoft Visual C++ 5.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 5.0 Professional Edition
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual C++ 6.0 Standard Edition
- Microsoft Visual C++ .NET 2002 Standard Edition
- Microsoft Visual C++ .NET 2003 Standard Edition
- Microsoft ActiveX Template Library 3.0, when used with:
- Microsoft Visual C++ 5.0 Enterprise Edition
- Microsoft Visual C++ 6.0 Enterprise Edition
- Microsoft Visual C++ 5.0 Professional Edition
- Microsoft Visual C++ 6.0 Professional Edition
- Microsoft Visual C++ 6.0 Standard Edition
- Microsoft Visual C++ .NET 2002 Standard Edition
- Microsoft Visual C++ .NET 2003 Standard Edition
This article was previously published under Q187644
SYMPTOMS
When an ATL-based ActiveX control has the focus on a Visual
Basic form, it does not give the focus to the default button on the form (the
button with a Default property of True) when you press ENTER.
Steps to Reproduce Behavior
- Add an ActiveX control that was written in ATL to a Visual
Basic form.
- Add a Command button to the form. Set the Default property
to True.
- Add an ActiveX control that was not written in ATL to the
form.
- Implement the Click event for the Command button as
follows:
Private Sub Command1_Click()
MsgBox "Hello from Command1"
End Sub
- Run the form. Select the ActiveX control that was not
written in ATL and press ENTER. This causes the default Command button to
activate and the message box appears.
- Select the ATL-based control and press ENTER. The Command
button does not get activated and the message box does not appear.
CAUSE
The reason for this behavior is that the default
implementation in ATL of the IOleControlImpl::GetControlInfo() and
IOleInPlaceActiveObjectImpl::TranslateAccelerator() methods just returns
E_NOTIMPL. The container calls GetControlInfo to get the control's keyboard
mnemonics and keyboard behavior, and it calls TranslateAccelerator() to process
the keys.
RESOLUTION
Because the implementation in ATL of these
IOleControlImpl-based methods simply returns E_NOTIMPL, the control writer must
override these methods in the control class.
STATUS
Microsoft is researching this problem and will post new
information here in the Microsoft Knowledge Base as it becomes available.
REFERENCES
Visual C++ Help; search on "IOleControl::GetControlInfo"
and "IOleInPlaceActiveObject::TranslateAccelerator"
For additional
information, please see the following article in the Microsoft Knowledge Base:
179696 PRB: Focus and Tab Issues with ATL Subclassed Edit Control
Additional query words: ATL Tabbing SubEdit GetControlInfo TranslateAccelerator
IOleControl IOleControlImpl kbATL200 kbATL210 kbCtrl kbVC500 kbDSupport kbdsd
kbatl300 kbvc600
Keywords: kbtshoot kbctrlcreate kbkeyaccel kbprb kbacceleratorkey KB187644