BUG: Unloading a Form After Assigning Text Property Causes GPFLast reviewed: October 8, 1996Article ID: Q150184 |
The information in this article applies to:
SYMPTOMSIf 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.
STATUSMicrosoft 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.
WORKAROUNDRather 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 IfTo 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 = &HF060so the following statement closes down Form2:
PostMessage Form2.hWnd, WM_SYSCOMMAND, SC_CLOSE, NILL MORE INFORMATION
Steps To Reproduce Problem
The instruction at "0x00428646" referenced memory at "0x00d10cd8". The memory could not be "read".In another test with, the 16-Bit Edition of Visual Basic, the error message was:
VB caused a General Protection Fault in module VB.EXE at 0016:2BFB.To work around the problem, place the declaration given in the Workaround Section above in the General Declarations section of Form2, and change the code in the DblClick event of the Text box on Form2 to:
Private Sub Text1_DblClick() Const NILL = 0& Const WM_SYSCOMMAND = &H112 Const SC_CLOSE = &HF060 Form1.Text1.Text = Text1.Text PostMessage Form2.hWnd, WM_SYSCOMMAND, SC_CLOSE, NILL End Sub |
Additional reference words: 4.00 vb4win vb4all
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |