即時嘗試更改自定義控件的進度欄的顏色。香港專業教育學院tryed不少methords像使用下面的sendingmessage功能:進度條更改顏色
<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
,但對我來說這沒有工作我couldent看到任何改變。
什麼將是我改變這種控制的前景的最佳方式?我無法使用PercentFull.ForeColor,因爲我將啓用xp樣式。
謝謝
沒有,但它是一個自定義的控制,所以我不必須禁用XP樣式的選項。這個控制也可以用於XP機器。謝謝。 – Houlahan