Date: 02-16-2022
Return to Index
created by gbSnippets
'If you do not know the state of all threads in your process,
'it is better to call TerminateProcess than ExitProcess.
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
%IDC_Button = 500
Global hDlg As Dword
Function PBMain() As Long
Dialog New Pixels, 0, "Test: Started at " + Time$,300,300,225,60, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %IDC_Button,"Restart", 50,10,100,20
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Select Case Cb.Msg
Case %WM_InitDialog
Settings_INI "get"
Case %WM_Command
Select Case Cb.Ctl
Case %IDC_Button
DestroyStuff
Local pid As Dword
pid = Shell(EXE.Full$,1) 'run this app
ExitProcess 0 'terminate ourself
End Select
Case %WM_Destroy
? "wm_destroy"
DestroyStuff
End Select
End Function
Sub DestroyStuff
'put whatever stuff should be in %WM_Destroy
Settings_INI "save"
End Sub
Sub Settings_INI(Task$)
Local x,y As Long, xResult,yResult,INIFileName As Asciiz*%Max_Path
INIFileName = EXE.Path$ + "myapp.ini"
If Task$ = "get" Then
Getprivateprofilestring "All", "Left", "300", xResult, %Max_Path, INIFileName
Getprivateprofilestring "All", "Top", "300", yResult, %Max_Path, INIFileName
Dialog Set Loc hDlg, Val(xResult), Val(yResult) 'left/top
End If
If Task$ = "save" Then
If IsFalse(IsIconic(hDlg) Or IsZoomed(hDlg)) Then
Dialog Get Loc hDlg To x,y
WritePrivateProfileString "All", "Left", Str$(x), INIFileName
WritePrivateProfileString "All", "Top", Str$(y), INIFileName
End If
End If
End Sub
'gbs_00724
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm