How to return a value to the main form ?

Started by Jean-pierre Leroy, May 07, 2012, 12:31:44 PM

Previous topic - Next topic

Jean-pierre Leroy

Dear all,

I've a very simple question.

I have a project with two forms: FORM1 and FORM2

On FORM1, there is a button to display FORM2; to do that I use the code below:


'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
                                   ControlIndex     As Long,  _  ' index in Control Array
                                   hWndForm         As Dword, _  ' handle of Form
                                   hWndControl      As Dword, _  ' handle of Control
                                   idButtonControl  As Long   _  ' identifier of button
                                   ) As Long
                                   
    Local lReturnValue As Long                                   

    FF_TextBox_SetText(HWND_FORM1_TEXT1,"")                                   
    lReturnValue = FORM2_SHOW(HWND_FORM1, %TRUE)
    FF_TextBox_SetText(HWND_FORM1_TEXT1,Str$(lReturnValue))                                     

End Function


On FORM2, there is button to close the FORM2 and returned a value to FORM1; to do that I use the code below:


'--------------------------------------------------------------------------------
Function FORM2_COMMAND1_BN_CLICKED ( _
                                   ControlIndex     As Long,  _  ' index in Control Array
                                   hWndForm         As Dword, _  ' handle of Form
                                   hWndControl      As Dword, _  ' handle of Control
                                   idButtonControl  As Long   _  ' identifier of button
                                   ) As Long                                   
    FF_CloseForm(hWndForm, 2012)                                   

End Function


So everything is working as expected as long as the user uses the button on FORM2 to close the current form. in this case with the FF_Close() function it's very easy to return a value to the calling program. but if the user clicks on the "X" close button or press Alt+F4 on FORM2 no value is returned to FORM1.

I know there is probably an obvious solution for that ...

Thanks
Jean-Pierre

Gary Robinson

Function FORM2_COMMAND1_WM_DESTROY ( _
                                   ControlIndex  As Long,  _  ' index in Control Array
                                   hWndForm      As Dword, _  ' handle of Form
                                   hWndControl   As Dword  _  ' handle of Control
                                   ) As Long

'makes both forms close
'FF_CloseForm(hWndForm, HWND_FORM2)

'make new copy of form, so there would be 2 form1's
'Local lReturnValue As Long
'lReturnValue = FORM1_SHOW(HWND_FORM1, %TRUE)

'control goes to form1
FF_Control_Enable( HWND_FORM1)
End Function

Gary Robinson

Sorry, I send wrong information.  Perhaps this is what you are looking for.

Search for: How to pass many parameters to a FORM
in
FireFly3 Private Member Forums > Archived FireFly2 Posts > FireFly2 (archived topics - read only)  in second page.