Microsoft KB Archive/172673
Article ID: 172673
Article Last Modified on 5/13/2003
- Microsoft Visual Basic 5.0 Learning Edition
- Microsoft Visual Basic 6.0 Learning Edition
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
- Microsoft Visual Basic 6.0 Enterprise Edition
This article was previously published under Q172673
When you set the Visible property of a control to True at run-time, the active control loses focus. The control for which you changed the Visible property gains the focus.
This problem occurs with the Sheridan 3D controls (SSRibbon, SOption, SSPanel, SSCommand, SSFrame and SSCheck).
NOTE: This problem will occur with other controls created with the MFC Control FrameWork.
To work around this problem, set the focus back to the control that was active prior to changing the Visible property of the Sheridan 3D control. The following code illustrates how you can restore focus to the active control after changing the Visible property of a SSPanel control:
Dim ctrl as Control Set ctrl = ActiveControl SSPanel1.Visible = True ctrl.SetFocus
NOTE: This code does not prevent the LostFocus and GotFocus event from firing when focus is inadvertently set to the Sheridan 3D control.
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
Steps to Reproduce Behavior
- Open a new "Standard EXE" project.
- Click Components on the Project menu. Check "Sheridan 3D Controls" (THREED32.OCX) and click OK.
NOTE: If you do not have THREED32.OCX installed, refer to README.TXT in the \Tools\Controls directory of your Visual Basic 5.0 CD-ROM.
- Add an SSPanel control and a TextBox control to Form1.
- Set the Visible property of the SSPanel control to False.
Add the following code to the Click event of Form1.
SSPanel1.Visible = True Debug.Print ActiveControl.Name
- Press the F5 key to run the application.
- Set the focus to Text1 and then click the Form. Notice that the SSPanel control has the focus and not Text1 as expected.
Additional query words: 3-D activex ocx mfc c++ kbVBp500bug kbVBp600bug kbVBp kbdsd kbDSupport kbControl
Keywords: kbbug KB172673