Lionheart008
01-10-2010, 12:37
hello. I wanted to add a new colour to progressbar example. what's missing ?
help manual says something like that:
a) ProgressBar_SetBarColor(hWnd, ctrlID, lColor)
b) ProgressBar_SetBkColor(hWnd, ctrlID, lColor)
translated for me:
a) ProgressBar_SetBarColor( CBHNDL, %ID_PROGRESS_1, Rgb(255,100,100) ) b) ProgressBar_SetBkColor(CBHNDL, %ID_PROGRESS_1, rgb(250,100,100) )
I've tried both ways, but without success:
'------------ ok ? -------------------------------------------------
ProgressBar_SetBarColor( CBHNDL, %ID_PROGRESS_1, Rgb(255,100,100) )
Control Set Color CBHNDL, %ID_PROGRESS_2, Rgb(100,200,60), %BLUE '---> works! :)
'------------ ok ? -------------------------------------------------
I have token progressbar example from sample script folder.
uses "UI"
begin const
%ID_BUTTON_OK = 1000
%ID_BUTTON_CANCEL
%ID_PROGRESS_1
%ID_PROGRESS_2
%ID_PROGRESS_3
%ID_STATUSBAR
end const
randomize
function TBMain()
dim hDlg as long
DIALOG NEW 0, "thinBasic Progress bar demo", -1, -1, 300, 160, _
%WS_DLGFRAME | _
%ds_center | _
%WS_CAPTION | _
%WS_SYSMENU | _
%WS_CLIPSIBLINGS | _
%WS_CLIPCHILDREN | _
%WS_OVERLAPPEDWINDOW , _
0 TO hDlg
DIALOG SHOW modal hDlg, call dlgCallback
end function
callback function dlgCallback() as long
dim x, y as long
dim MaxSteps as long
dim Counter as long
'---Now test the message
SELECT CASE cbMsg
case %WM_INITDIALOG '---Message fired at the very beginning when dialog is initialized
'---Status Bar
Control Add statusbar, cbHndl, %ID_STATUSBAR, "", , , , , %SBARS_SIZEGRIP | %WS_CHILD | %WS_VISIBLE
'---Define parts
StatusBar_SetParts cbHndl, %ID_STATUSBAR, 100, 200, -1
'---Set icons in each part
statusbar_SetIcon cbHndl, %ID_STATUSBAR, 1, app_sourcepath & "bt_down.ico", 0
statusbar_SetIcon cbHndl, %ID_STATUSBAR, 2, app_sourcepath & "bt_play.ico", 0
statusbar_SetIcon cbHndl, %ID_STATUSBAR, 3, app_sourcepath & "bt_Up.ico", 0
'---Add a standard window progress bar and ...
Control Add ProgressBar, CBHNDL, %ID_PROGRESS_1, "", 5, 5, 290, 12, %WS_CHILD | %WS_VISIBLE | %PBS_SMOOTH | %PBS_MARQUEE
Control Add ProgressBar, CBHNDL, %ID_PROGRESS_2, "", 5, 20, 290, 12, %WS_CHILD | %WS_VISIBLE
Control Add ProgressBar, CBHNDL, %ID_PROGRESS_3, "", 5, 35, 12, 60, %WS_CHILD | %WS_VISIBLE | %PBS_VERTICAL | %PBS_SMOOTH
ProgressBar_SetMarquee CBHNDL, %ID_PROGRESS_1, %TRUE, Rnd(50, 150)
ProgressBar_SetBkColor(CBHNDL, %ID_PROGRESS_1, rgb(250,100,100) )
'------------ ok ? -------------------------------------------------
'ProgressBar_SetBarColor( CBHNDL, %ID_PROGRESS_1, Rgb(255,100,100) )
'Control Set Color CBHNDL, %ID_PROGRESS_2, Rgb(100,200,60), %BLUE '---> works! :)
'------------ ok ? -------------------------------------------------
control set resize cbHndl, %ID_PROGRESS_1, 1, 1, 0, 0
control set resize cbHndl, %ID_PROGRESS_2, 1, 1, 0, 0
control set resize cbHndl, %ID_PROGRESS_3, 1, 0, 1, 1
CONTROL ADD BUTTON, cbHndl, %ID_BUTTON_OK, "&Start", 40, 110, 50, 14, %BS_DEFAULT
CONTROL ADD BUTTON, cbHndl, %ID_BUTTON_CANCEL, "&Close", 110, 110, 50, 14
control set resize cbHndl, %ID_BUTTON_OK , 0, 0, 0, 1
control set resize cbHndl, %ID_BUTTON_CANCEL, 0, 0, 0, 1
CASE %WM_COMMAND
SELECT CASE cbCtl
case %ID_BUTTON_CANCEL
dialog end cbHndl
case %ID_BUTTON_OK
control disable cbHndl, %ID_BUTTON_OK
control disable cbHndl, %ID_BUTTON_CANCEL
Control Get Loc CBHNDL, %ID_BUTTON_OK To x, y
MaxSteps = 500 '---Set max range
'---SetUp progress bar 2
ProgressBar_SetRange cbHndl, %ID_PROGRESS_2, 0, MaxSteps '---Set PB min and max values
ProgressBar_SetStep cbHndl, %ID_PROGRESS_2, 1 '---Set automatic step increment
ProgressBar_SetPos cbHndl, %ID_PROGRESS_3, 0 '---Set current bar position
'------------ ok ? -------------------------------------------------
ProgressBar_SetBarColor( CBHNDL, %ID_PROGRESS_1, Rgb(255,100,100) )
Control Set Color CBHNDL, %ID_PROGRESS_2, Rgb(100,200,60), %BLUE '---> works ?
'------------ ok ? -------------------------------------------------
'---SetUp progress bar 3
ProgressBar_SetRange cbHndl, %ID_PROGRESS_3, 0, MaxSteps '---Set PB min and max values
ProgressBar_SetStep cbHndl, %ID_PROGRESS_3, 1 '---Set automatic step increment
ProgressBar_SetPos cbHndl, %ID_PROGRESS_3, 0 '---Set current bar position
StatusBar_Settext cbHndl, %ID_STATUSBAR, "Min: 0", 1
StatusBar_Settext cbHndl, %ID_STATUSBAR, "Current 0", 2
StatusBar_Settext cbHndl, %ID_STATUSBAR, "Max: " & MaxSteps, 3
'---Progress values in ascending order
for Counter = 1 to MaxSteps
ProgressBar_Stepit cbHndl, %ID_PROGRESS_2
ProgressBar_Stepit cbHndl, %ID_PROGRESS_3
StatusBar_Settext cbHndl, %ID_STATUSBAR, "Current " & ProgressBar_GetPos (cbHndl, %ID_PROGRESS_2), 2
doevents
next
'---Invert the auto increment step from 1 to -1
ProgressBar_SetStep cbHndl, %ID_PROGRESS_2, -1 '---Set automatic step increment
ProgressBar_SetStep cbHndl, %ID_PROGRESS_3, -1 '---Set automatic step increment
'---Progress values in descending order
for Counter = 1 to MaxSteps
ProgressBar_Stepit cbHndl, %ID_PROGRESS_2
ProgressBar_Stepit cbHndl, %ID_PROGRESS_3
StatusBar_Settext cbHndl, %ID_STATUSBAR, "Current " & ProgressBar_GetPos (cbHndl, %ID_PROGRESS_2), 2
doevents
next
'---Clear status bar text parts in one go using -1 in part number
StatusBar_SetText CBHNDL, %ID_STATUSBAR, "", -1
control enable cbHndl, %ID_BUTTON_OK
control enable cbHndl, %ID_BUTTON_CANCEL
END SELECT
END SELECT
end function
little tipp would be good to find right solution.
best regards, frank
help manual says something like that:
a) ProgressBar_SetBarColor(hWnd, ctrlID, lColor)
b) ProgressBar_SetBkColor(hWnd, ctrlID, lColor)
translated for me:
a) ProgressBar_SetBarColor( CBHNDL, %ID_PROGRESS_1, Rgb(255,100,100) ) b) ProgressBar_SetBkColor(CBHNDL, %ID_PROGRESS_1, rgb(250,100,100) )
I've tried both ways, but without success:
'------------ ok ? -------------------------------------------------
ProgressBar_SetBarColor( CBHNDL, %ID_PROGRESS_1, Rgb(255,100,100) )
Control Set Color CBHNDL, %ID_PROGRESS_2, Rgb(100,200,60), %BLUE '---> works! :)
'------------ ok ? -------------------------------------------------
I have token progressbar example from sample script folder.
uses "UI"
begin const
%ID_BUTTON_OK = 1000
%ID_BUTTON_CANCEL
%ID_PROGRESS_1
%ID_PROGRESS_2
%ID_PROGRESS_3
%ID_STATUSBAR
end const
randomize
function TBMain()
dim hDlg as long
DIALOG NEW 0, "thinBasic Progress bar demo", -1, -1, 300, 160, _
%WS_DLGFRAME | _
%ds_center | _
%WS_CAPTION | _
%WS_SYSMENU | _
%WS_CLIPSIBLINGS | _
%WS_CLIPCHILDREN | _
%WS_OVERLAPPEDWINDOW , _
0 TO hDlg
DIALOG SHOW modal hDlg, call dlgCallback
end function
callback function dlgCallback() as long
dim x, y as long
dim MaxSteps as long
dim Counter as long
'---Now test the message
SELECT CASE cbMsg
case %WM_INITDIALOG '---Message fired at the very beginning when dialog is initialized
'---Status Bar
Control Add statusbar, cbHndl, %ID_STATUSBAR, "", , , , , %SBARS_SIZEGRIP | %WS_CHILD | %WS_VISIBLE
'---Define parts
StatusBar_SetParts cbHndl, %ID_STATUSBAR, 100, 200, -1
'---Set icons in each part
statusbar_SetIcon cbHndl, %ID_STATUSBAR, 1, app_sourcepath & "bt_down.ico", 0
statusbar_SetIcon cbHndl, %ID_STATUSBAR, 2, app_sourcepath & "bt_play.ico", 0
statusbar_SetIcon cbHndl, %ID_STATUSBAR, 3, app_sourcepath & "bt_Up.ico", 0
'---Add a standard window progress bar and ...
Control Add ProgressBar, CBHNDL, %ID_PROGRESS_1, "", 5, 5, 290, 12, %WS_CHILD | %WS_VISIBLE | %PBS_SMOOTH | %PBS_MARQUEE
Control Add ProgressBar, CBHNDL, %ID_PROGRESS_2, "", 5, 20, 290, 12, %WS_CHILD | %WS_VISIBLE
Control Add ProgressBar, CBHNDL, %ID_PROGRESS_3, "", 5, 35, 12, 60, %WS_CHILD | %WS_VISIBLE | %PBS_VERTICAL | %PBS_SMOOTH
ProgressBar_SetMarquee CBHNDL, %ID_PROGRESS_1, %TRUE, Rnd(50, 150)
ProgressBar_SetBkColor(CBHNDL, %ID_PROGRESS_1, rgb(250,100,100) )
'------------ ok ? -------------------------------------------------
'ProgressBar_SetBarColor( CBHNDL, %ID_PROGRESS_1, Rgb(255,100,100) )
'Control Set Color CBHNDL, %ID_PROGRESS_2, Rgb(100,200,60), %BLUE '---> works! :)
'------------ ok ? -------------------------------------------------
control set resize cbHndl, %ID_PROGRESS_1, 1, 1, 0, 0
control set resize cbHndl, %ID_PROGRESS_2, 1, 1, 0, 0
control set resize cbHndl, %ID_PROGRESS_3, 1, 0, 1, 1
CONTROL ADD BUTTON, cbHndl, %ID_BUTTON_OK, "&Start", 40, 110, 50, 14, %BS_DEFAULT
CONTROL ADD BUTTON, cbHndl, %ID_BUTTON_CANCEL, "&Close", 110, 110, 50, 14
control set resize cbHndl, %ID_BUTTON_OK , 0, 0, 0, 1
control set resize cbHndl, %ID_BUTTON_CANCEL, 0, 0, 0, 1
CASE %WM_COMMAND
SELECT CASE cbCtl
case %ID_BUTTON_CANCEL
dialog end cbHndl
case %ID_BUTTON_OK
control disable cbHndl, %ID_BUTTON_OK
control disable cbHndl, %ID_BUTTON_CANCEL
Control Get Loc CBHNDL, %ID_BUTTON_OK To x, y
MaxSteps = 500 '---Set max range
'---SetUp progress bar 2
ProgressBar_SetRange cbHndl, %ID_PROGRESS_2, 0, MaxSteps '---Set PB min and max values
ProgressBar_SetStep cbHndl, %ID_PROGRESS_2, 1 '---Set automatic step increment
ProgressBar_SetPos cbHndl, %ID_PROGRESS_3, 0 '---Set current bar position
'------------ ok ? -------------------------------------------------
ProgressBar_SetBarColor( CBHNDL, %ID_PROGRESS_1, Rgb(255,100,100) )
Control Set Color CBHNDL, %ID_PROGRESS_2, Rgb(100,200,60), %BLUE '---> works ?
'------------ ok ? -------------------------------------------------
'---SetUp progress bar 3
ProgressBar_SetRange cbHndl, %ID_PROGRESS_3, 0, MaxSteps '---Set PB min and max values
ProgressBar_SetStep cbHndl, %ID_PROGRESS_3, 1 '---Set automatic step increment
ProgressBar_SetPos cbHndl, %ID_PROGRESS_3, 0 '---Set current bar position
StatusBar_Settext cbHndl, %ID_STATUSBAR, "Min: 0", 1
StatusBar_Settext cbHndl, %ID_STATUSBAR, "Current 0", 2
StatusBar_Settext cbHndl, %ID_STATUSBAR, "Max: " & MaxSteps, 3
'---Progress values in ascending order
for Counter = 1 to MaxSteps
ProgressBar_Stepit cbHndl, %ID_PROGRESS_2
ProgressBar_Stepit cbHndl, %ID_PROGRESS_3
StatusBar_Settext cbHndl, %ID_STATUSBAR, "Current " & ProgressBar_GetPos (cbHndl, %ID_PROGRESS_2), 2
doevents
next
'---Invert the auto increment step from 1 to -1
ProgressBar_SetStep cbHndl, %ID_PROGRESS_2, -1 '---Set automatic step increment
ProgressBar_SetStep cbHndl, %ID_PROGRESS_3, -1 '---Set automatic step increment
'---Progress values in descending order
for Counter = 1 to MaxSteps
ProgressBar_Stepit cbHndl, %ID_PROGRESS_2
ProgressBar_Stepit cbHndl, %ID_PROGRESS_3
StatusBar_Settext cbHndl, %ID_STATUSBAR, "Current " & ProgressBar_GetPos (cbHndl, %ID_PROGRESS_2), 2
doevents
next
'---Clear status bar text parts in one go using -1 in part number
StatusBar_SetText CBHNDL, %ID_STATUSBAR, "", -1
control enable cbHndl, %ID_BUTTON_OK
control enable cbHndl, %ID_BUTTON_CANCEL
END SELECT
END SELECT
end function
little tipp would be good to find right solution.
best regards, frank