Win32 - Change FG/BG color of a Progressbar

Share your advanced PureBasic knowledge/code with the community.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Win32 - Change FG/BG color of a Progressbar

Post by BackupUser »

Code updated for 5.20+

Restored from previous forum. Originally posted by MrVainSCL.

Hi dudes,
here is a small example, showing you how to change the forground and background color of any Progressbar in you application.

Code: Select all

; ------------------------------------------------------------
;
; PureBasic Win32 API - ChangeProgressbarColor - Example v1.0
;
; by MrVainSCL! aka Thorsten   20/Jan/2003    PB v3.51+
;
; ------------------------------------------------------------
;
#WindowWidth  = 450
#WindowHeight = 100
;
title$ = "PB3.51 API - Colored Progressbar"
;
; ------------------------------------------------------------
; Init API constants for Progressbar
;
#WM_USER         = $400               ; one of the standard window messages
#CCM_FIRST       = $2000              ; one of the commoncontrols messages
#CCM_SETBKCOLOR  = #CCM_FIRST + 1     ; one of the commoncontrols messages
#CLR_DEFAULT     = $FF000000          ; Return constant for #PBM_SETBARCOLOR and #PBM_SETBKCOLOR
#PBM_SETBARCOLOR = #WM_USER   + 9     ; Set a new color for the progressbar (forground color)
#PBM_SETBKCOLOR  = #CCM_SETBKCOLOR    ; Set a new color for the progressbar (background color)
;
; ------------------------------------------------------------
;
OpenWindow(0,0,0, #WindowWidth, #WindowHeight, title$, #PB_Window_SystemMenu |#PB_Window_WindowCentered)
;
; -------- Set forground/background color for Progressbar --------
; 
hPBG1 = ProgressBarGadget(3, 10, 40, #WindowWidth-25, 20, 0, 100)
SendMessage_(hPBG1, #PBM_SETBKCOLOR, 0, RGB(0,255,255))
SendMessage_(hPBG1, #PBM_SETBARCOLOR, 0, RGB(255,0,0))
;
; -------- Update the ProgressBar - Part 1 --------
;
For k=0 To 100
  SetGadgetState(3, k)
  Delay(30)
Next
;
; -------- Update the ProgressBar - Part 2 --------
;
For k=0 To 100
  SendMessage_(hPBG1, #PBM_SETBKCOLOR, 0, RGB(0,0,80))
  SendMessage_(hPBG1, #PBM_SETBARCOLOR, 0, RGB(200-k*2,k*2,0))
  SetGadgetState(3, k)
  Delay(30)
Next
;   
; ------------------------------------------------------------
;
Repeat
  EventID = WaitWindowEvent()
Until EventID = #PB_Event_CloseWindow
End
;   
; ------------------------------------------------------------

Note: Minimum operating systems to get it work:
Windows 2000, Windows NT 4.0 with Internet Explorer 4.0, Windows 98, Windows 95 with Internet Explorer 4.0


PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...

greetz
MrVainSCL! aka Thorsten
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

Code: Select all

; by Feri, 04.01.2003 (german forum)
;
; Farben im ProgressBarGadget ändern 
; ---------------------------------- 
OpenWindow(0,300,500,270,30,#PB_Window_SystemMenu,"Testfenster") 
; 
  SetWinBackgroundColor(WindowID(0),RGB(0,0,0))             ;  Hintergrundfarbe des Window ändern 
; 
CreateGadgetList(WindowID()) 
  ProgressBarGadget(1,10,10,250,10,0,1000,#PB_ProgressBar_Smooth) 
;  
  SendMessage_(GadgetID(1),#CCM_SETBKCOLOR,0,RGB(60,50,0))  ;  Hintergrundfarbe im ProgressBarGadget ändern 
  SendMessage_(GadgetID(1),#WM_USER+9,0,RGB(250,220,80))    ;  Balkenfarbe des ProgressBarGadget ändern 
; 
SetGadgetState(1,500)    ;   als Beispielwert 
; 
Repeat 
Until WaitWindowEvent() = #PB_EventCloseWindow 
End 
cya,
...Danilo
(registered PureBasic user)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

nice - lets vote danilo for president!

greetz
MrVainSCL! aka Thorsten

PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Manolo.
Originally posted by MrVainSCL

nice - lets vote danilo for president!

greetz
MrVainSCL! aka Thorsten

PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
Sorry, but SetWinBackgroundColor not is un regular command in purebasic.
Manolo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Henrik.

Cool..
The Progressbar thing.

But, but, Germany is sooo close, but your politically system.. tsk tsk
I don't think i ever gonna understand that one.
Everybody wants you to vote for somebody else.

regards

Henrik.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by freak.

> Sorry, but SetWinBackgroundColor not is un regular command in purebasic.

I think, it's Danilo's SkinWin Library.
get it from the recource Site.

Timo
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by MrVainSCL.

Yes, its Danilo´s SkinWin Lib... Get version 1.0 (2002-Mar-29)at:
http://www.reelmediaproductions.com/pb/ ... nwin10.zip

greetz
MrVainSCL! aka Thorsten

PIII450, 256MB Ram, 80GB HD + 6,4 GB, RivaTNT, DirectX9.0, SB AWE64, Win2000 + all Updates...
Post Reply