Lionheart008
11-12-2009, 21:23
hello, good evening.
I wanted to translate a powerbasic example to thinbasic. perhaps anybody can check this progressbar behaviour according to the "marquee" effect. I didn't find this little thing to run.
progressbar example:
' Empty GUI script created on 12-11-2009 11:50:20 by (ThinAIR)
Uses "console", "ui"
%WM_USER = &H400
%ID_PROGRESS = %WM_USER + 2048
%ID_PROGRLBL = %WM_USER + 2049
%ID_PROGRLBL2 = %WM_USER + 2050
%ID_STATUSBAR = %WM_USER + 2051
Sub ShowProgressDialog (ByVal hParent As DWord)
Local hDlg As DWord
Dialog NEW hParent, "Status Loading..",-1,-1, 200, 70, %DS_MODALFRAME Or %WS_CAPTION, 0 To hDlg
Dialog SET COLOR hDlg, -1, RGB(192,192,222)
Control ADD LABEL, hDlg, %ID_PROGRLBL, "Processing:", 5, 2, 190, 10
Control SET COLOR hDlg, %ID_PROGRLBL, -1, RGB(192,192,222)
Control ADD LABEL, hDlg, %ID_PROGRLBL2, "Processed:", 55, 32, 90, 10, %SS_CENTER
Control SET COLOR hDlg, %ID_PROGRLBL2, -1, RGB(192,192,222)
Control ADD BUTTON, hDlg, %IDCANCEL, "Cancel", 70, 50, 60, 14
Control ADD PROGRESSBAR, hDlg, %ID_PROGRESS, "", 5, 12, 190, 12, %WS_CHILD Or %WS_VISIBLE
Dialog SHOW MODAL hDlg, Call PBarDlgProc
End Sub
CallBack Function PBarDlgProc () As Long
Local hwnd As Long
Local i As Long
Local lMax As Long
Static Abort As Long
Static range As Long
Local progressbars As Long
Select Case CBMSG
Case %WM_INITDIALOG
Dialog POST CBHNDL, %WM_USER + 999&, 0, 0
Case %WM_USER + 999&
Abort = 0
lMax = 400
Dialog REDRAW CBHNDL
Control ADD PROGRESSBAR, hwnd, %ID_PROGRESS,"loading", 20,20,120,60, %WS_CHILD | %WS_VISIBLE | %PBS_SMOOTH | %PBS_MARQUEE
ProgressBar_SetRange CBHNDL, %ID_PROGRESS, 0, lMax
ProgressBar_SetStep CBHNDL, %ID_PROGRESS, 1
ProgressBar_SetPos CBHNDL, %ID_PROGRESS, 0
ProgressBar_SetMarquee CBHNDL, %ID_PROGRESS, %TRUE, Rnd(50, 150)
Control SET RESIZE CBHNDL, %ID_PROGRESS, 1, 1, 0, 0
For i = 1 To lMax
SLEEP 20
Control SET TEXT CBHNDL, %ID_PROGRLBL, "Loading processes #" & Str$(i)
Control SET TEXT CBHNDL, %ID_PROGRLBL2, Format$(i / lMax, "#%"" done""")
Dialog DoEvents
If Abort Then Exit For
Next
Dialog End CBHNDL
Case %WM_COMMAND
Select Case CBCTL
Case %IDCANCEL
If CBCTLMSG = %BN_CLICKED Then
If MsgBox 0,"Abort the process?", _
%MB_YESNO Or %MB_ICONQUESTION Or %MB_ICONINFORMATION, _
"Abort?" = %IDYES Then Abort = %TRUE
Dialog REDRAW CBHNDL
End If
End Select
Case %WM_SYSCOLORCHANGE
Control SEND CBHNDL, %ID_PROGRESS, CBMSG, CBWPARAM, CBLPARAM
End Select
End Function
CallBack Function MainDlgProc () As Long
Select Case CBMSG
Case %WM_COMMAND
Select Case CBCTL
Case %IDOK
If CBCTLMSG = %BN_CLICKED Then
ShowProgressDialog CBHNDL
End If
Case %IDCANCEL
If CBCTLMSG = %BN_CLICKED Then
Dialog End CBHNDL
End If
End Select
End Select
End Function
Function TBMAIN () As Long
Local hDlg As DWord
Dialog FONT "Comic Sans MS", 18
Dialog NEW 0, "Thinbasic Progress bar demo",-1,-1, 140, 100, %WS_CAPTION Or %WS_SYSMENU To hDlg
Dialog SET COLOR hDlg, -1, RGB(222,192,192)
Control ADD LABEL, hDlg, -1, "push start button for progress bar", 5, 35, 130, 10, %SS_CENTER
Control SET COLOR hDlg, -1, -1, RGB(222,192,192)
Control ADD BUTTON, hDlg, %IDOK, "Start", 18, 80, 50, 14
Control ADD BUTTON, hDlg, %IDCANCEL, "Close", 72, 80, 50, 14
Dialog FONT "Arial", 9
Dialog SHOW MODAL hDlg Call MainDlgProc
End Function
salve, pace diem, frank
I wanted to translate a powerbasic example to thinbasic. perhaps anybody can check this progressbar behaviour according to the "marquee" effect. I didn't find this little thing to run.
progressbar example:
' Empty GUI script created on 12-11-2009 11:50:20 by (ThinAIR)
Uses "console", "ui"
%WM_USER = &H400
%ID_PROGRESS = %WM_USER + 2048
%ID_PROGRLBL = %WM_USER + 2049
%ID_PROGRLBL2 = %WM_USER + 2050
%ID_STATUSBAR = %WM_USER + 2051
Sub ShowProgressDialog (ByVal hParent As DWord)
Local hDlg As DWord
Dialog NEW hParent, "Status Loading..",-1,-1, 200, 70, %DS_MODALFRAME Or %WS_CAPTION, 0 To hDlg
Dialog SET COLOR hDlg, -1, RGB(192,192,222)
Control ADD LABEL, hDlg, %ID_PROGRLBL, "Processing:", 5, 2, 190, 10
Control SET COLOR hDlg, %ID_PROGRLBL, -1, RGB(192,192,222)
Control ADD LABEL, hDlg, %ID_PROGRLBL2, "Processed:", 55, 32, 90, 10, %SS_CENTER
Control SET COLOR hDlg, %ID_PROGRLBL2, -1, RGB(192,192,222)
Control ADD BUTTON, hDlg, %IDCANCEL, "Cancel", 70, 50, 60, 14
Control ADD PROGRESSBAR, hDlg, %ID_PROGRESS, "", 5, 12, 190, 12, %WS_CHILD Or %WS_VISIBLE
Dialog SHOW MODAL hDlg, Call PBarDlgProc
End Sub
CallBack Function PBarDlgProc () As Long
Local hwnd As Long
Local i As Long
Local lMax As Long
Static Abort As Long
Static range As Long
Local progressbars As Long
Select Case CBMSG
Case %WM_INITDIALOG
Dialog POST CBHNDL, %WM_USER + 999&, 0, 0
Case %WM_USER + 999&
Abort = 0
lMax = 400
Dialog REDRAW CBHNDL
Control ADD PROGRESSBAR, hwnd, %ID_PROGRESS,"loading", 20,20,120,60, %WS_CHILD | %WS_VISIBLE | %PBS_SMOOTH | %PBS_MARQUEE
ProgressBar_SetRange CBHNDL, %ID_PROGRESS, 0, lMax
ProgressBar_SetStep CBHNDL, %ID_PROGRESS, 1
ProgressBar_SetPos CBHNDL, %ID_PROGRESS, 0
ProgressBar_SetMarquee CBHNDL, %ID_PROGRESS, %TRUE, Rnd(50, 150)
Control SET RESIZE CBHNDL, %ID_PROGRESS, 1, 1, 0, 0
For i = 1 To lMax
SLEEP 20
Control SET TEXT CBHNDL, %ID_PROGRLBL, "Loading processes #" & Str$(i)
Control SET TEXT CBHNDL, %ID_PROGRLBL2, Format$(i / lMax, "#%"" done""")
Dialog DoEvents
If Abort Then Exit For
Next
Dialog End CBHNDL
Case %WM_COMMAND
Select Case CBCTL
Case %IDCANCEL
If CBCTLMSG = %BN_CLICKED Then
If MsgBox 0,"Abort the process?", _
%MB_YESNO Or %MB_ICONQUESTION Or %MB_ICONINFORMATION, _
"Abort?" = %IDYES Then Abort = %TRUE
Dialog REDRAW CBHNDL
End If
End Select
Case %WM_SYSCOLORCHANGE
Control SEND CBHNDL, %ID_PROGRESS, CBMSG, CBWPARAM, CBLPARAM
End Select
End Function
CallBack Function MainDlgProc () As Long
Select Case CBMSG
Case %WM_COMMAND
Select Case CBCTL
Case %IDOK
If CBCTLMSG = %BN_CLICKED Then
ShowProgressDialog CBHNDL
End If
Case %IDCANCEL
If CBCTLMSG = %BN_CLICKED Then
Dialog End CBHNDL
End If
End Select
End Select
End Function
Function TBMAIN () As Long
Local hDlg As DWord
Dialog FONT "Comic Sans MS", 18
Dialog NEW 0, "Thinbasic Progress bar demo",-1,-1, 140, 100, %WS_CAPTION Or %WS_SYSMENU To hDlg
Dialog SET COLOR hDlg, -1, RGB(222,192,192)
Control ADD LABEL, hDlg, -1, "push start button for progress bar", 5, 35, 130, 10, %SS_CENTER
Control SET COLOR hDlg, -1, -1, RGB(222,192,192)
Control ADD BUTTON, hDlg, %IDOK, "Start", 18, 80, 50, 14
Control ADD BUTTON, hDlg, %IDCANCEL, "Close", 72, 80, 50, 14
Dialog FONT "Arial", 9
Dialog SHOW MODAL hDlg Call MainDlgProc
End Function
salve, pace diem, frank