The ATL controls does not recognize the default button on a VB form in Visual C++ (187644)
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 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
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ .NET (2003)
- 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 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
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ .NET (2003)
- The Microsoft Active Template Library (ATL) 3.0, when used with:
- 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
- Microsoft Visual C++ .NET (2002)
- Microsoft Visual C++ .NET (2003)
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
Modification Type: | Major | Last Reviewed: | 6/4/2005 |
---|
Keywords: | kbtshoot kbAcceleratorKey kbCtrlCreate kbKeyAccel kbprb KB187644 kbAudDeveloper |
---|
|