Microsoft KB Archive/233199

= BUG: Duplicate Control Boxes on MDI Form =

Article ID: 233199

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q233199



SYMPTOMS
If you have user controls on MDI child forms, the MDI form will sometimes display duplicate control boxes when you close it. This problem only occurs when the focus is on the user control when the child form is closed.



RESOLUTION
There are two ways to work around this problem:
 * 1) Mark the user control's focus property as False so that it does not receive focus.
 * 2) Add at least one control that is not a user control on your child form. Set the focus to this control right before the child form is closed.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Open a new Visual Basic Standard EXE project. Form1 is created by default. On the Project menu, click Add MDI Form to add MDIForm1 to the project. Set Form1's MDIChild property to True. On the Project menu, click Project1 Properties. On the General tab, change the StartUp Object to MDIForm1 and click OK. On the Project menu, click Add User Control to add a UserControl to the project. Usercontrol1 is created by default. Close UserControl1's design window so that it can be sited on a form. Add a UserControl11 to Form1.</li>  Add the following code to the General Declarations section of MDIForm1: Private Sub MDIForm_DblClick Dim frm As Form1 Set frm = New Form1 frm.Show End Sub </li> Press the F5 key to run the project. Double-click the MDIForm three times to instantiate three instances of Form1. Minimize two of the child forms and maximize one. Click the Close button "x" in the control box to close the first child window. Click it again to close the second child form. A duplicate set of control boxes will be added to the title bar.</li></ol>

Steps to Work Around the Behavior
<ol> Add a TextBox control to Form1.</li>  Add following code to the General Declarations section of Form1: Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) Text1.SetFocus End Sub </li> Repeat the procedure from step 8 above. The duplicate control boxes do not appear.</li></ol>

Keywords: kbbug kbctrl kbpending KB233199

-

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

© Microsoft Corporation. All rights reserved.