BUG: DBGrid on a Modal Form Can Cause a Program to Hang (150206)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
This article was previously published under Q150206 SYMPTOMS
A program hangs if a DBGrid control is placed on a Modal Form, which itself
was invoked from a Modal form from an MDIChild window, and the form
containing the DBGrid is then closed. Usually the window receiving the
focus after the form with the DBGrid control is closed begins to flash, and
does not respond to user input.
STATUS
Microsoft has confirmed this to be an issue in the Microsoft products
listed at the beginning of this article. Microsoft is researching this
issue and will post new information here in the Microsoft Knowledge Base
as it becomes available.
WORKAROUND
Show the form containing the DBGrid in a non-modal fashion, and disable the
other forms in the project until the non-modal form is dismissed. The
routine below shows a form that appears as a modal form:
Public Sub ShowModalForm(frmTarget As Form)
Dim c As Collection
Set c = New Collection
'Disable all the forms
For Each ofrm In Forms
If ofrm.Enabled = True Then
c.Add ofrm
ofrm.Enabled = False
End If
Next ofrm
'Now show the target form non-modal
frmTarget.Show
'If the frmTarget was disabled by the loop above
'(because it was invisible) make sure it is now enabled
frmTarget.Enabled = True
'Sit in a loop until the target form is dismissed
Do While frmTarget.Visible = True
DoEvents
Loop
'FIX: Unload the Form
UnLoad frmTarget
'We have left the loop, so the dialog has been closed
'Now Enable the forms that were disabled, and exit the procedure
For Each ofrm In c
ofrm.Enabled = True
Next ofrm
End Sub
Because a non-modal form cannot be shown from a modal form, the routine
above must also be used to show the form prior to the modal form containing
the DBGrid control.
Modification Type: | Major | Last Reviewed: | 6/28/2004 |
---|
Keywords: | kbbug KB150206 |
---|
|