Hi all....
I want to do the VB equivalent of:
form1 show
form2 hide
and vice versa....
in Firefly. I have read the help file but I can't get it to work. If my two forms are called FORM1 and FORM2, can someone show me real code examples of making FORM2 appear and hiding FORM1?
Thanks
Patrick
Example: In Form1, I have a CommandButton that when clicked will show Form2.
'------------------------------------------------------------------------------------------------------------------------
Function FORM1_COMMAND2_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
' Show Form2 when the CommandButton is clicked
Form2_Show hWndForm, 1 ' display as modal form
End Function
In Form2's WM_CREATE message I place the following code to hide Form1.
'------------------------------------------------------------------------------------------------------------------------
Function FORM2_WM_CREATE ( _
hWndForm As Dword, _ ' handle of Form
ByVal UserData As Long _ 'optional user defined Long value
) As Long
' Hide Form1
FF_Control_ShowState HWND_FORM1, %SW_HIDE
End Function
Also, I make Form1 re-appear when Form2 is destroyed.
'------------------------------------------------------------------------------------------------------------------------
Function FORM2_WM_DESTROY ( _
hWndForm As Dword _ ' handle of Form
) As Long
' Show Form1 when Form2 closes
FF_Control_ShowState HWND_FORM1, %SW_SHOW
End Function
Thanks for the examples... I also seemed to get the following working:
berry=form2_show(hwnd_form1,%true)
What's the difference?
Patrick
Check out the Help file topic "Handling Multiple Forms". Basically, you are using the function version that returns a value when the Form is closed. This enables you to do things like detect when the user has closed your popup form via pressing an "OK" or "Cancel" button.
If the user presses "OK" you can put something like the following in the BN_CLICKED message handler:
FF_CloseForm hWndForm, %TRUE 'return a TRUE value to the calling form.
Likewise, in the "Cancel" BN_CLICKED message handler you could put:
FF_CloseForm hWndForm, %FALSE
In your form's code that calls the second popup form you can then use logic like this:
If Form2_Show( hwndForm, %TRUE) Then
msgbox "The user clicked OK to close the popup form"
Else
msgbox "The user cancelled the popup form"
End If
Thanks for the info....
The line below works fine when I use it inside a command button:
Form2_Show hWndForm, 1
But if I try to use it inside FF_WINMAIN it doesn't work because there is no hWndForm variable to pass to it. So, if I want to start Form1 and then switch to FORM2 from FF_WINMAIN, can I? How can I define hwndform or what do I define it as?
Thanks for all the help
patrick
I don't really understand what it is you're trying to do because I don't see why you would want to do this in FF_WINMAIN. FF_WINMAIN executes prior to any form being shown which also means that there is no message pump, etc existing at that point.
If you want Form1 to show when your application starts then simply set Form1 as the "Startup Form" under "Project Properties". From that Form1 then you can show Form2 when you deem it necessary.
Are you trying to do a splash screen type of thing, or something like that ????
1) Well, the first time the program is run, it checks to see if a text file exists in C:\ and if it does not, I want it to goto form2. Subsequent times the program is run, it will see that the needed text file is there and then it would remain on form1.
2) Also, how can I change the caption of an RRbutton programatically? I went to the website mentioned elsewhere in the forum but all its help is geared to non-firefly users... I tried obvious things like rbutton1.caption="xxx" but that didn't work... I want to change its captions at various times...
Thanks
Patrick
Make Form1 your Startup form.
In the WM_CREATE message of Form1 put code like the following:
'------------------------------------------------------------------------------------------------------------------------
Function FORM1_WM_CREATE ( _
hWndForm As Dword, _ ' handle of Form
ByVal UserData As Long _ 'optional user defined Long value
) As Long
Local txtFilename As String
txtFilename = "mytextfile.txt"
If Dir$(txtFilename) = "" Then
'the text file does not exist, show Form2. When Form2 is displayed, Form1
'will be hidden (via the WM_CREATE message in Form2).
Form2_Show hWndForm, %TRUE
End If
End Function
In Form2, put code like the following:
'------------------------------------------------------------------------------------------------------------------------
Function FORM2_WM_CREATE ( _
hWndForm As Dword, _ ' handle of Form
ByVal UserData As Long _ 'optional user defined Long value
) As Long
' Hide Form1
FF_Control_ShowState HWND_FORM1, %SW_HIDE
End Function
'------------------------------------------------------------------------------------------------------------------------
Function FORM2_WM_DESTROY ( _
hWndForm As Dword _ ' handle of Form
) As Long
' Show Form1 when Form2 closes
FF_Control_ShowState HWND_FORM1, %SW_SHOW
End Function
For your second question: Borje's RRButton handles many different kinds of messages. They are listed in the RRButton.inc file. From your post I get the feeling that you are an ex-Visual Basic programmer ??? You can send messages to controls using the function, SendMessage. You use the window handle for the control in question and send it the wParam and lParam parameteres. Those parameters are always different because they depend on message is being sent.
For example, to set the roundness of the RRButton via code, you can do the following:
SendMessage HWND_FORM1_RRBUTTON1, %RBM_SETCORNER, 5, %TRUE
Setting the caption is a bit easier because you can use the FireFly Function to do that rather than having to use a SendMessage. I think that you also need to redraw the control when the text is changed.
FF_Control_SetText HWND_FORM1_RRBUTTON1, "New Caption"
FF_Control_Redraw HWND_FORM1_RRBUTTON1
Thanks Paul - I really appreciate you being so patient - trust me when I say I am documenting all your answers so I at least won't have to you those questions again!
Patrick