FIX: Unloading a Form After Assigning Text Property Causes GPF (150184)
The information in this article applies to:
- Microsoft Visual Basic Standard Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Professional Edition, 32-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 16-bit, for Windows 4.0
- Microsoft Visual Basic Enterprise Edition, 32-bit, for Windows 4.0
This article was previously published under Q150184 SYMPTOMS
If the Text property of a Text box is set equal to the Text property of a
Text box on a separate modal form, and if that statement is followed by
unloading the modal form, a General Protection Fault results.
RESOLUTION
Rather than use the Unload statement to unload the modal dialog box, use
the PostMessage API function. The declaration for PostMessage is:
#If Win32 Then
Private Declare Function PostMessage Lib "user32" Alias _
"PostMessageA"(ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
#Else
Private Declare Function PostMessage Lib "User" (ByVal hWnd As Integer,
ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As
Integer
#End If
To post a close message for a form, set the first parameter to the hWnd of
the target form, and the other three parameters as specified below:
Const NILL = 0&
Const WM_SYSCOMMAND = &H112
Const SC_CLOSE = &HF060
so the following statement closes down Form2:
PostMessage Form2.hWnd, WM_SYSCOMMAND, SC_CLOSE, NILL
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.
Modification Type: | Minor | Last Reviewed: | 7/16/2004 |
---|
Keywords: | kbBug kbfix kbVBp600fix KB150184 |
---|
|