Microsoft KB Archive/172111

= FIX: Visual Basic 5.0 Focus Is Not Returned to a MDI Form After a Dialog Is Shown =

Article ID: 172111

Article Last Modified on 12/10/2003

-

APPLIES TO


 * Microsoft Visual Basic 5.0 Learning Edition
 * Microsoft Visual Basic 5.0 Professional Edition
 * Microsoft Visual Basic 5.0 Enterprise Edition
 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q172111



SYMPTOMS
In the versions of Microsoft Visual Basic listed at the beginning of this article, if an MDI Form's Enabled property is set to False before a CommonDialog (such as ShowOpen) is displayed, the focus does not return to the MDI form, even if it is set programmatically. The subsequent behavior is that instead of giving the MDI form the focus, focus is given to the last window that had focus before the MDI form.



RESOLUTION
The current workaround for this confirmed bug is to not set the MDI Form's Enabled property to False. The CommonDialog is Modal and automatically disables the MDI Form because of its Modal nature. Thus the workaround code for the code example in this article is:

Private Sub Picture1_Click CommonDialog1.ShowOpen End Sub



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been fixed in Visual Basic 6.0.



Steps to Reproduce Behavior
 Start Visual Basic. Form1 is created by default. Add a MDI Form (MDIForm1) to the Project. Make the MDI Form the Startup Form. Add a Common Dialog Control (CommonDialog1) to the MDIForm1. Add a Picture Box Control (Picture1) to the MDIForm1.  Add the following code to the Picture1_Click Event: Private Sub Picture1_Click MDIForm1.Enabled = False CommonDialog1.ShowOpen MDIForm1.Enabled = True End Sub

</li> Run the project. Note that the focus does not return to the MDIForm1. Instead the focus is sent to the next available window.

NOTE: This behavior did not occur with the Cmdialog.vbx that shipped with Visual Basic 3.0.</li></ol>

Additional query words: kbVBp300bug kbVBp400bug kbVBp500bug kbVBp600fix kbVBp kbdsd kbDSupport kbControl kbMDI

Keywords: kbbug kbfix kbgrpdsvb KB172111

-

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

© Microsoft Corporation. All rights reserved.