PRB: MFC Control Does Not Detect Keystrokes When SSTabs Exist (195238)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q195238 SYMPTOMS
An MFC-based ActiveX control cannot gain input focus when an SSTab control
is on the same form. This only happens when you click the MFC control (at
which time the MFC control should get the input focus) right after you have
clicked one of the SSTab's tab pages. The control works as expected when
there is no SSTab on the form or when you click the MFC control after
clicking other controls, such as the Visual Basic intrinsic TextBox. As an
example, if the MFC control aggregates a child Edit box control, and if you
click it right after you've clicked the SSTab's tab page, nothing can be
typed into your MFC control's Edit box.
CAUSE
MFC ActiveX controls UI-Activate themselves when they receive the mouse-
click message. If you have a child control inside your COleControl, mouse-
click messages on the child control are not sent to the COleControl and MFC
does not UI-Activate the ActiveX control, even though the child control has
just been given the keyboard focus. When the SSTab gets the focus, your
control needs to explicitly UI-Activate itself to actually get the input
focus when you click the control.
RESOLUTION
There are two ways to resolve the problem. The first method needs to change
the MFC control's source code. The idea is to UI-Activate the whole control
whenever your control is activated. Usually, this is done with an event
handler, such as the following:
int CMyEditCtlAppCtrl::OnMouseActivate(CWnd* pDesktopWnd,
UINT nHitTest, UINT message)
{
OnActivateInPlace (TRUE, NULL); // UI-Activate the control
return COleControl::OnMouseActivate(pDesktopWnd, nHitTest, message);
}
The second method changes the Visual Basic code. The only change that needs
to be made is to call the SetFocus method of one of the controls on the
form in the SSTab1_Click event handler. Then, after you click the SSTab
control, other controls on the form can get the input focus.
STATUS
This behavior is by design.
Modification Type: | Major | Last Reviewed: | 5/13/2003 |
---|
Keywords: | kbcode kbCtrl kbprb KB195238 |
---|
|