我正在尝试更改自定义控件的进度条颜色。我尝试了很多方法,例如使用下面的发送消息功能:
<DllImport("User32.Dll")> _ Public Shared Function SendMessage(hwnd As Integer, wMsg As Integer, wParam As Integer, lParam As Integer) As Integer End Function
Public Const PBM_SETBKCOLOR As Integer = &H2001
Public Const PBM_SETBARCOLOR As Integer = &H409
Public Sub SetProgressBackColor(c As Color)
Dim a As Integer = Convert.ToInt32(c.R.ToString())
Dim b As Integer = Convert.ToInt32(c.G.ToString())
Dim d As Integer = Convert.ToInt32(c.B.ToString())
Dim tot As Integer = Convert.ToInt32(ColorTranslator.ToOle(Color.FromArgb(a, b, d)).ToString())
Dim j As Integer = Me.PercentFull.Handle.ToInt32()
SendMessage(j, PBM_SETBKCOLOR, 0, tot)
End Sub
Public Sub SetProgressForeColor(c As Color)
Dim a As Integer = Convert.ToInt32(c.R.ToString())
Dim b As Integer = Convert.ToInt32(c.G.ToString())
Dim d As Integer = Convert.ToInt32(c.B.ToString())
Dim tot As Integer = Convert.ToInt32(ColorTranslator.ToOle(Color.FromArgb(a, b, d)).ToString())
Dim j As Integer = Me.PercentFull.Handle.ToInt32()
SendMessage(j, PBM_SETBARCOLOR, 0, tot)
End Sub
但这对我不起作用,我看不到任何变化。
我更改此控件的前景色的最佳方法是什么?我不能使用 PercentFull.ForeColor,因为我将启用 xp 样式。
谢谢