PDA

View Full Version : progress bar color ?



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

Petr Schreiber
01-10-2010, 13:17
Hi Frank,

as the help file says:

When visual styles are enabled, this message has no effect.

This option works without any obstacles on Windows9x/ME systems.
On XP and newer the styling is enabled by default for ThinBASIC apps (I think, Eros will know better), so you will not see the color change for progressbar control.


Petr

Lionheart008
03-10-2010, 01:13
thanks petr for reply :)

It's an advantage feature for Thinbasic development or what else ? (*grinning*)

How I can realize this feature of showing ? ;) for powerbasic that was no problem :)

perhaps you can take in contact to eros. or its a feature for next issue. I have no problem with that one. otherwise you have any other example to show how to use progress bar with different background color? I think you have done and managed this one before ?

nice evening, frank

Petr Schreiber
03-10-2010, 10:50
Ciao Frank,

if you wish to have colorful progressbars and would have use for it, please do not hesitate to post a request in Suggest new features forum.


Petr