Tools Links Login

Change background/foreground color of Progressbar

Change background/foreground color of Progressbar.
using SENDMESSAGE/win32API

Original Author: Juha Söderqvist

API Declarations

Public Declare Function SendMessage Lib _
"user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Public Const CCM_FIRST = &H2000
Public Const CCM_SETBKCOLOR = (CCM_FIRST + 1)
Public Const PBM_SETBKCOLOR = CCM_SETBKCOLOR
Public Const WM_USER = &H400
Public Const PBM_SETBARCOLOR = (WM_USER + 9)

Code

' -------------- module code --------------
Public Declare Function SendMessage Lib _
"user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
  ByVal wMsg As Long, _
  ByVal wParam As Long, _
  lParam As Any) As Long
Public Const CCM_FIRST = &H2000
Public Const CCM_SETBKCOLOR = (CCM_FIRST + 1)
Public Const PBM_SETBKCOLOR = CCM_SETBKCOLOR
Public Const WM_USER = &H400
Public Const PBM_SETBARCOLOR = (WM_USER + 9)
' to change progressbarcolor

Public Sub colortoprogress(prog As Long, bgr As Integer, bgg As Integer, bgb As Integer, fgr As Integer, fgg As Integer, fgb As Integer)
SendMessage prog, PBM_SETBKCOLOR, 0, ByVal RGB(bgr, bgg, bgb)
SendMessage prog, PBM_SETBARCOLOR, 0, ByVal RGB(fgr, fgg, fgb)
End Sub


' -------------- form code --------------
Private Sub Form_Load()
Me.ProgressBar1.Scrolling = ccScrollingSmooth
Me.ProgressBar1.Min = 0
Me.ProgressBar1.Max = 100
colortoprogress Me.ProgressBar1.hwnd, 255, 255, 255, 0, 0, 0
Timer1.Interval = 10
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Me.ProgressBar1.visible = True
If Me.ProgressBar1.Value = 100 Then Me.ProgressBar1.Value = 1
Me.ProgressBar1.Value = Me.ProgressBar1.Value + 1
End Sub

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 124 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.