Hi there
In my program, when a user clicks "File New" I would like to restart the program as if it wasn't running. My use of Globals makes it a nightmare to try and figure out what is happening even though I kept track of the variables and reset them. On the PB site. I read a few ways to do it but all seems to involve WinMain().
So how and where could I introduce a restart code?
thanx
Bert
Can you point to a link on the PB site so I can see what it is you want to do? Once I know exactly the sequence of events that you need to happen then I should be able to guide you through adapting it to FireFly.
Hi Paul here is a few
http://www.powerbasic.com/support/forums/Forum4/HTML/013999.html (http://www.powerbasic.com/support/forums/Forum4/HTML/013999.html)
http://www.powerbasic.com/support/forums/Forum4/HTML/005801.html (http://www.powerbasic.com/support/forums/Forum4/HTML/005801.html)
http://www.powerbasic.com/support/forums/Forum4/HTML/012938.html (http://www.powerbasic.com/support/forums/Forum4/HTML/012938.html)
hope this helps
Bert
Maybe I am missing something very basic.... but the following seems to work quite well. Place the Shell code in the WM_DESTROY of the main/startup Form of your application. When the application is terminating, the WM_DESTROY code will be executed. It checks to see if a global variable (gRestart) has been set to TRUE and if it has, then the application is restarted. Use FireFly's built-in "App" variable to get the program path and EXE name.
Global gRestart As Long
Function FORM1_WM_DESTROY ( _
hWndForm As Dword _ ' handle of Form
) As Long
Local nResult As Long
If gRestart = %TRUE Then
nResult = Shell( App.Path & App.EXEname, 0 )
End If
End Function
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
gRestart = %TRUE
End Function