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