-1

using the progressbar control i can only use the default green one.

Looking in windows 7 i have noticed this control, see image below.

enter image description here

I found this article: Windows ProgressBar

My question is, how to use this control in Visual Studio 2013 labelling a blue progress bar?

thanks

Edit: i would like the blue color, not the red, yellow or green one. This control is called "meter".

2 Answers2

-1

I found a way to change the colors, but no blue... But I suppose it's done via the same way

Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        MyProgressBar1.pdColor = myProgressBar.ProgressBarColor.red
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        MyProgressBar1.Increment(1)
    End Sub
End Class

Public Class myProgressBar
    Inherits ProgressBar

    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    Public Sub New()
    End Sub

    Enum ProgressBarColor
        green = 1
        red = 2
        yellow = 3
    End Enum

    Private pbColor As ProgressBarColor
    Public Property pdColor As ProgressBarColor
        Get
            Return pbColor
        End Get
        Set(value As ProgressBarColor)
            pbColor = value
            SendMessage(Me.Handle, 1040, value, 0)
        End Set
    End Property

End Class
Veeke
  • 229
  • 1
  • 6
-1

Sorry but its not Accessible as stated:

In Windows Vista, progressbars come in different flavors, the most common progressbar being the green one. However, there are also the red and yellow versions as well (there is a blue version, known as a meter, but that is inaccessible). The progressbar colors seem to correspond to specific progressbar states. You can set these states using the PBM_SETSTATE [0x40F] message. The states are PBST_NORMAL [0x0001], PBST_ERROR [0x0002] and PBST_PAUSE [0x0003].

But if you are interested it is possible to access the Red and Yellow Color using the following:

Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Enum ProgressBarColor
    Green = &H1
    Red = &H2
    Yellow = &H3
End Enum

Private Shared Sub ChangeProgBarColor(ByVal ProgressBar_Name As ProgressBar, ByVal ProgressBar_Color As ProgressBarColor)
    SendMessage(ProgressBar_Name.Handle, &H410, ProgressBar_Color, 0)
End Sub

Example of Usage:

ChangeProgBarColor(Progress_Bar, ProgressBarColor.Red)
user1931470
  • 193
  • 1
  • 6