VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Change background/foreground color of Progressbar

by Juha s�derqvist (4 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 3.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (6 Votes)

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

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)

Rate Change background/foreground color of Progressbar

' -------------- 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

Download this snippet    Add to My Saved Code

Change background/foreground color of Progressbar Comments

No comments have been posted about Change background/foreground color of Progressbar. Why not be the first to post a comment about Change background/foreground color of Progressbar.

Post your comment

Subject:
Message:
0/1000 characters