Abort a form

Started by BudDurland, June 03, 2009, 03:41:34 PM

Previous topic - Next topic

BudDurland

Is there a way to abort loading/displaying a form?  I though returning %True from the _wm_create function would do it, but apparently not.  The best I can think of is to post a message to the form to close.

TechSupport

I think you're right. Post a message.

If it is a popup Form that you're about to show then you could initially create that Form with WS_VISIBLE unchecked at design time. That way you won't get an annoying flash of the Form on scree before it is closed.


%MSG_USER_CLOSEFORM = %WM_USER + 1


'------------------------------------------------------------------------------------------------------------------------
Function FORM2_WM_CREATE ( _
                         hWndForm As Dword, _  ' handle of Form
                         ByVal UserData As Long _  'optional user defined Long value
                         ) As Long
   
   
   PostMessage hWndForm, %MSG_USER_CLOSEFORM, 0, 0
   
End Function


'------------------------------------------------------------------------------------------------------------------------
Function FORM2_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_USER_CLOSEFORM
         FF_CloseForm hWndForm
         
   End Select
     
End Function