[VB6] Progress bar color?-VBForums
Results 1 to 10 of 10

Thread: [VB6] Progress bar color?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2004
    Posts
    64

    Resolved [VB6] Progress bar color?

    Can you change the color of the progress bar?

    Thanks
    Last edited by ChaosBlizzard; Mar 1st, 2005 at 06:59 PM.

  2. #2
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627

    Re: [VB6] Progress bar color?

    This one can. I use it in a couple app's, it works very well.

    http://www.smartdownloads.net/download-22208.html
    Here's to us!
    Who's like us?
    Darned few, and they're all dead!

  3. #3
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,088

    Re: [VB6] Progress bar color?

    No purchase of a control needed.
    VB Code:
    1. '<VBOutlookGuru 05/30/03 - CHANGE PROGRESSBAR COLOR>
    2. Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
    3. ByVal wParam As Long, ByVal lParam As Long) As Long
    4.  
    5. Private Const PBM_SETBARCOLOR As Long = &H409
    6. Private Const PBM_SETBKCOLOR As Long = &H2001
    7. Private Const PROGBAR_DEF_COLOR = &HFF000000 '&H8000000D
    8.  
    9. 'Usage -
    10. Call SendMessageLong(ProgressBar1.hwnd, PBM_SETBARCOLOR, 0&, ByVal 255) 'Red
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  4. #4
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627

    Re: [VB6] Progress bar color?


    Oh, didn't see he's charging for it now. It's a good control that allows lots of features for the progress bar if you have the extra 20 bucks or whatever. But, looks like robdogg's method is the cheap way.
    Here's to us!
    Who's like us?
    Darned few, and they're all dead!

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2004
    Posts
    64

    Re: [VB6] Progress bar color?

    Quote Originally Posted by RobDog888
    No purchase of a control needed.
    VB Code:
    1. '<VBOutlookGuru 05/30/03 - CHANGE PROGRESSBAR COLOR>
    2. Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
    3. ByVal wParam As Long, ByVal lParam As Long) As Long
    4.  
    5. Private Const PBM_SETBARCOLOR As Long = &H409
    6. Private Const PBM_SETBKCOLOR As Long = &H2001
    7. Private Const PROGBAR_DEF_COLOR = &HFF000000 '&H8000000D
    8.  
    9. 'Usage -
    10. Call SendMessageLong(ProgressBar1.hwnd, PBM_SETBARCOLOR, 0&, ByVal 255) 'Red
    That looks better that most other color changing codes.. But it sends off an error stating that ProgressBar1.hwnd is an invalid procedure in this line:
    Call SendMessageLong(ProgressBar1.hwnd, PBM_SETBARCOLOR, 0&, ByVal 255)

  6. #6
    Fanatic Member demotivater's Avatar
    Join Date
    Jun 2002
    Location
    is everything
    Posts
    627

    Re: [VB6] Progress bar color?

    Put that line in a command button, or wherever you want it to run from, not with the declarations.
    Here's to us!
    Who's like us?
    Darned few, and they're all dead!

  7. #7
    Super Moderator RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,088

    Re: [VB6] Progress bar color?

    Here is a working example.
    VB Code:
    1. 'Behind form1
    2. Option Explicit
    3. 'Add one progressbar to your form (ProgressBar1)
    4. 'Add two command buttons (Command1 & Command2)
    5. '<VBOutlookGuru 05/30/03 - CHANGE PROGRESSBAR COLOR>
    6. Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
    7. ByVal wParam As Long, ByVal lParam As Long) As Long
    8.  
    9. Private Const PBM_SETBARCOLOR As Long = &H409
    10. Private Const PBM_SETBKCOLOR As Long = &H2001
    11. Private Const PROGBAR_DEF_COLOR = &HFF000000 '&H8000000D
    12.  
    13. Private sub form_Load()
    14.     Progressbar1.max = 100
    15.     Progressbar1.value = 50
    16. End Sub
    17.  
    18. Private sub Command1_Click() 'Changes the prb to red
    19.     Call SendMessageLong(ProgressBar1.hwnd, PBM_SETBARCOLOR, 0&, ByVal 255) 'Red
    20. End Sub
    21.  
    22. Private Sub COmmand2_Click() 'Changes it back to system default
    23.     Call SendMessageLong(ProgressBar1.hwnd, PBM_SETBARCOLOR, 0&, ByVal PROGBAR_DEF_COLOR) 'Default system color
    24. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Star Wars Gangsta Rap Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel Core 2 Extreme Ed., 2 WD Raptor 10K RPM 300 GB HDs, 2 GBs DDR2 667 MHz RAM, 2 Viewsonic 24" LCDs, Windows 7 SP-1/Windows 8.1, Office 2010, VS 2013

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Nov 2004
    Posts
    64

    Re: [VB6] Progress bar color?

    That codes for a progress bar that changes color when you click a button?.

    I just wanted to change it period, you know have a static color. I don't need anything interactive.

  9. #9
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,633

    Re: [VB6] Progress bar color?

    Errr...
    Code:
    Option Explicit
    
    Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
    ByVal wParam As Long, ByVal lParam As Long) As Long
    
    Private Const PBM_SETBARCOLOR As Long = &H409
    Private Const PBM_SETBKCOLOR As Long = &H2001
    Private Const PROGBAR_DEF_COLOR = &HFF000000 '&H8000000D
    
    Private sub Form_Load()
        Progressbar1.max = 100
        Progressbar1.value = 50
        ChangeColorOfProgBar
    End Sub
    
    Private sub ChangeColorOfProgBar
        Call SendMessageLong(ProgressBar1.hwnd, PBM_SETBARCOLOR, 0&, ByVal 255) 'Red
    End Sub
    Woof

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Nov 2004
    Posts
    64

    Resolved Re: [VB6] Progress bar color?

    Hey that works! LOL

    Sorry and thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.