Hey guys, getting an odd error , and even gettting an odder work around
when trying to close forms. I have small form generated just to collect a file name from the user. they input the text and press enter, then i want the form to close.
odd i get a crash happen when i try to do this . below is an example of when it crashed...
'------------------------------------------------------------------------------------------------------------------------
Function NEWFOLDER_T_CUSTOM ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
wMsg As Long, _ ' type of message
wParam As Dword, _ ' first message parameter
lParam As Long _ ' second message parameter
) As Long
If wMsg = 135 And wparam = %VK_RETURN Then
FF_CloseForm hwnd_filename , %TRUE
Exit Function
End If
End Function
very strange but if I create a thread function with basically the line
FF_CloseForm hwnd_filename , %TRUE
in it , then it also crashes
but when using Dialog End hwnd_newfolder in the thread its fine .
not usre if i explained my self well enough or not let me know.
Paul.
I assume that closing the form from within the subclassed handler for the TextBox is causing a null pointer at some point. The easiest way to fix this is to post a custom message to the Form from within the TextBox handler. Posting a message allows the current code in the TextBox handler to fully complete. When the Form receives the custom message then it can close the Form.
It is easier to show via an example rather than explain:
%MSG_CLOSE_FORM = %WM_USER + 100
'------------------------------------------------------------------------------------------------------------------------
Function FORM1_TEXT1_CUSTOM ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
wMsg As Long, _ ' type of message
wParam As Dword, _ ' first message parameter
lParam As Long _ ' second message parameter
) As Long
Select Case wMsg
Case %WM_KEYUP
If wParam = %VK_RETURN Then
PostMessage hWndForm, %MSG_CLOSE_FORM, 0, 0
End If
End Select
End Function
'------------------------------------------------------------------------------------------------------------------------
Function FORM1_CUSTOM ( _
hWndForm As Dword, _ ' handle of Form
wMsg As Long, _ ' type of message
wParam As Dword, _ ' first message parameter
lParam As Long _ ' second message parameter
) As Long
Select Case wMsg
Case %MSG_CLOSE_FORM
FF_CloseForm hWndForm
End Select
End Function
Thanks for the response. IL have to keep the message in mind next time . its something i keep coming across and have avoided in a few imaginative ways.
thanks again
PAul