Microsoft KB Archive/185477

= BUG: ActiveX Control in MDI Child Form Does Not Maintain Focus =

Article ID: 185477

Article Last Modified on 3/10/2005

-

APPLIES TO


 * 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 Q185477



SYMPTOMS
A multiple document interface (MDI) child form contains an ActiveX control, and the ActiveX control has the focus. When you leave and return to the MDI child form, the focus does not return to the ActiveX control.



RESOLUTION
To work around this problem, add Me.SetFocus to the GotFocus event of all ActiveX controls in the MDI child form.

For Example: Private Sub RichTextBox1_GotFocus Me.SetFocus End Sub



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.



Steps to Reproduce Behavior
 Start a new Standard EXE project in Visual Basic. Form1 is created by default. Add a reference to the Microsoft Rich TextBox Control 5.0 by completing the following steps:  From the Project menu, click Components to display the Components dialog box. In the Controls tab, check Microsoft Rich Textbox Control 5.0. Click OK to close the Components dialog box.</ol> </li> Add a TextBox and a Rich TextBox control to Form1. Set the MDIChild property of Form1 to True.</li> Add an MDI form to the project. From the Project menu, click Add MDI form. MDIForm1 is created by default.</li> Add a PictureBox control to the MDI form.</li> On the Run menu, click Start (or press the F5 key) to start the program.</li> Click on the TextBox control, and then click on the PictureBox control.</li> Click anywhere on the MDI child form except in the TextBox. Note that the cursor goes to the TextBox.</li> Repeat the same action but use the Rich TextBox control instead.

RESULTS: The cursor does not return to the Rich TextBox control.</li></ol>

To work around this problem, copy the following code to the code window of Form1: Option Explicit Private Sub RichTextBox1_GotFocus

Me.SetFocus

End Sub

Keywords: kbbug kbctrl kbpending KB185477

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.