Visual Studio Progressbar控件:蓝色

时间:2016-05-25 07:10:31

标签: vb.net progress-bar

使用进度条控件我只能使用默认的绿色控件。

在Windows 7中查看我已经注意到此控件,请参见下图。

enter image description here

我找到了这篇文章: Windows ProgressBar

我的问题是,如何在Visual Studio 2013中使用此控件标记蓝色进度条?

感谢

编辑:我想要蓝色,而不是红色,黄色或绿色。此控件称为" meter"。

2 个答案:

答案 0 :(得分:-1)

我找到了改变颜色的方法,但没有蓝色...... 但我认为它是以同样的方式完成的

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

答案 1 :(得分:-1)

很抱歉,但如上所述,它无法访问:

  

在Windows Vista中,progressbars有不同的风格,最多   常见的进度条是绿色的。但是,也有   红色和黄色版本(有一个蓝色版本,称为   米,但那是无法进入的)。进度条颜色似乎   对应于特定的进度条状态。您可以设置这些状态   使用PBM_SETSTATE [0x40F]消息。状态为PBST_NORMAL   [0x0001],PBST_ERROR [0x0002]和PBST_PAUSE [0x0003]。

但如果您感兴趣,可以访问红色和黄色 使用以下内容:

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

用法示例:

ChangeProgBarColor(Progress_Bar, ProgressBarColor.Red)