' Empty GUI script created on 01-06-2013 12:59:05 by (thinAir) Uses "console", "UI" Begin Const %ID_PROGRESS = 500 %ID_PROGRLBL %ID_PROGRLBL2 %IDD_DIALOG1 %IDC_PROGRESSBAR1 %IDC_PROGRESSBAR2 %ID_ScrollBar1 %IDC_LABEL1 %IDC_BUTTON1 %IDC_BUTTON2 %IDC_TEXTBOX1 %IDC_BUTTON3 End Const '--- good or better using %WM_INITDIALOG ? ---------- Function SetProgressBar(ByVal hDlg As Long, ByVal pPos As Long) As Long Control Add ProgressBar hDlg, %IDC_PROGRESSBAR1, pPos,14,50,20,40 Control Set Color hDlg, %IDC_PROGRESSBAR1, Rgb(100, 255, 0), Rgb(0, 255, 0) ProgressBar_SetMarquee hDlg, %IDC_PROGRESSBAR1, %TRUE, Rnd(50, 150) Control Set Resize hDlg, %IDC_PROGRESSBAR1, 1, 1, 0, 0 Control Set Text hDlg, %IDC_LABEL1, Str$(pPos)+"%" Control Set Text hDlg, %IDC_TEXTBOX1, Trim$(Str$(pPos)) End Function '-------------------------- Function TBMain () As Long ' MAIN '-------------------------- Local hDlg As DWord Dialog Font "Comic Sans", 14 Dialog New 0, "simple start gui",-1,-1, 160, 80, %WS_CAPTION Or %WS_SYSMENU To hDlg Dialog Set Color hDlg, -1, Rgb(200,180,220) Control Add Label, hDlg, -1, "push start to show next dialog", 5, 65, 130, 10, %SS_CENTER Control Set Color hDlg, -1, -1, Rgb(22,200,22) Control Add Button, hDlg, %IDOK, "&Start", 18, 40, 50, 14 Control Add Button, hDlg, %IDCANCEL, "&Close", 72, 40, 50, 14 Dialog Show Modal hDlg Call MyMainDlgProc End Function '-- cb one ------------------------------------- CallBack Function MyMainDlgProc () As Long Select Case CBMSG Case %WM_COMMAND Select Case CBCTL Case %IDOK If CBCTLMSG = %BN_CLICKED Then ShowProgressGui CBHNDL End If Case %IDCANCEL If CBCTLMSG = %BN_CLICKED Then Dialog End CBHNDL End If End Select End Select End Function Sub ShowProgressGui (ByVal hParent As Long) Local hDlg As Long Dialog New 0, "ProgressBar with Coloured Level (?)",-1,-1, 140, 200, _ %WS_POPUP Or _ %WS_VISIBLE Or _ %WS_CLIPCHILDREN Or _ %WS_CAPTION Or _ %WS_SYSMENU Or _ %WS_MINIMIZEBOX, _ 0 To hDlg Control Add ProgressBar, hDlg, %IDC_PROGRESSBAR1, "", 50, 15, 20, 100, _ %WS_CHILD Or %WS_VISIBLE Or %PBS_SMOOTH Or %PBS_VERTICAL Control Set Color hDlg, %IDC_PROGRESSBAR1, -1, Rgb(222,192,192) Control Add Label, hDlg, %IDC_LABEL1, "", 80, 60, 40, 10 Control Add Button, hDlg, %IDC_BUTTON1, "+", 10, 15, 25, 10 Control Add Button, hDlg, %IDC_BUTTON2, "-", 10, 105, 25, 10 Control Add Button, hDlg, %IDC_BUTTON3, "Accept", 50, 135, 70, 15 Control Add Textbox, hDlg, %IDC_TEXTBOX1,"", 10, 136, 25, 13, _ %ES_NUMBER Or %WS_TABSTOP Or %WS_BORDER Or %ES_LEFT, _ %WS_EX_CLIENTEDGE Or %WS_EX_LEFT Dialog Show Modal hDlg, Call ShowBarProc End Sub '-- cb two ------------------------------------- CallBack Function ShowBarProc() Local txty As String Local pPos As Long, MaxSteps As Long 'pPos = 500 Select Case CBMSG Case %WM_INITDIALOG SetProgressBar(CBHNDL,pPos) Control Add ProgressBar CBHNDL, %IDC_PROGRESSBAR1, pPos,14,50,20,40 ProgressBar_SetRange CBHNDL, %IDC_PROGRESSBAR1, 0, pPos ProgressBar_SetStep CBHNDL, %IDC_PROGRESSBAR1, 1 '---Set automatic step increment ProgressBar_SetPos CBHNDL, %IDC_PROGRESSBAR1, 0 '---Set current bar position ProgressBar_SetMarquee CBHNDL, %IDC_PROGRESSBAR1, %TRUE, Rnd(50, 150) Control Set Resize CBHNDL, %IDC_PROGRESSBAR1, 1, 1, 0, 0 Case %WM_COMMAND Select Case CBCTL Case %IDC_BUTTON1 MaxSteps = 500 ProgressBar_SetRange CBHNDL, %IDC_PROGRESSBAR1, 0, MaxSteps '---Set PB min and max values ProgressBar_SetStep CBHNDL, %IDC_PROGRESSBAR1, 1 '---Set automatic step increment ProgressBar_SetPos CBHNDL, %IDC_PROGRESSBAR1, 0 '---Set current bar position If CBCTLMSG = %BN_CLICKED Or CBCTLMSG = 1 Then pPos=Min(pPos+1,100) SetProgressBar(CBHNDL,pPos) End If Case %IDC_BUTTON2 If CBCTLMSG = %BN_CLICKED Or CBCTLMSG = 1 Then pPos=Max(pPos-1,0) SetProgressBar(CBHNDL,pPos) End If Case %IDC_BUTTON3 If CBCTLMSG = %BN_CLICKED Or CBCTLMSG = 1 Then Control Get Text CBHNDL, %IDC_TEXTBOX1 To txty pPos=Min(Val(txty),100) SetProgressBar(CBHNDL,pPos) End If End Select End Select End Function
Bookmarks