Hi,
I need to make a custom ProgressBar which allows me to set the Vista 3 state colors in addition to orientation, in .NetFx 4.8 WinForms, wrote this code but orientation will not apply, confused, any tip please? :)
Public Class _MeterBar
Inherits Windows.Forms.ProgressBar
Private _Vertical As Boolean = False
Private _Color As Color = Color.Green
Public Sub New()
MyBase.New()
'Style = ProgressBarStyle.Continuous
End Sub
Protected Overrides ReadOnly Property CreateParams As CreateParams
Get
If _Vertical = False Then
Dim MyCP As CreateParams = MyBase.CreateParams
MyCP.Style = MyCP.Style
Return MyCP
Else
Dim MyCP As CreateParams = MyBase.CreateParams
MyCP.Style = MyCP.Style Or &H4
Return MyCP
End If
End Get
End Property
Public Property ProgressVertical As Boolean
Get
Return _Vertical
End Get
Set(ByVal Vertical As Boolean)
_Vertical = Vertical
Invalidate()
End Set
End Property
Public Property ProgressColor As Color
Get
Return _Color
End Get
Set(ByVal PRGColor As Color)
Select Case PRGColor
Case Color.Yellow
_Color = Color.Yellow
If InvokeRequired Then
Invoke(Sub() SendMessage(Me.Handle, &H400 + 16, CType(&H3, IntPtr), IntPtr.Zero))
Else
SendMessage(Me.Handle, &H400 + 16, CType(&H3, IntPtr), IntPtr.Zero)
End If
Invalidate()
Case Color.Red
_Color = Color.Red
If InvokeRequired Then
Invoke(Sub() SendMessage(Me.Handle, &H400 + 16, CType(&H2, IntPtr), IntPtr.Zero))
Else
SendMessage(Me.Handle, &H400 + 16, CType(&H2, IntPtr), IntPtr.Zero)
End If
Invalidate()
Case Else
_Color = Color.Green
If InvokeRequired Then
Invoke(Sub() SendMessage(Me.Handle, &H400 + 16, CType(&H1, IntPtr), IntPtr.Zero))
Else
SendMessage(Me.Handle, &H400 + 16, CType(&H1, IntPtr), IntPtr.Zero)
End If
Invalidate()
End Select
End Set
End Property
End Class