掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
プログレスバーの色を変更するには??【.NET】 (ID:116547)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
> ProgressBar.BackColorや.ForeColorを変更するにはどうしたらいいのでしょうか。。 Comctl32.dll のバージョンが 4.71 以上であれば、色を変更する事は できるのですが、残念ながらそれは、.NET Framework の機能としては 用意されていないのです。 この場合は、Windows API を直接呼び出すことで、プログレスバーの色を 変更する事が可能です。もしも API を使いたくないなら、GDI+ を使って、 自分でプログレスバーを自作してしまうのも手でしょう。 <System.Runtime.InteropServices.StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)> Structure COLORREF Public Red As Byte Public Green As Byte Public Blue As Byte Public Sub New(ByVal Red As Byte, ByVal Green As Byte, ByVal Blue As Byte) Me.Red = Red Me.Green = Green Me.Blue = Blue End Sub Public Sub New(ByVal Color As System.Drawing.Color) Me.Red = Color.R Me.Green = Color.G Me.Blue = Color.B End Sub End Structure Private Declare Auto Function SendMessage Lib "user32" (ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As COLORREF) As Integer Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Const PBM_SETBKCOLOR As Integer = &H2001I Const PBM_SETBARCOLOR As Integer = &H0409I SendMessage( ProgressBar1.Handle, PBM_SETBKCOLOR , 0I, New COLORREF(Color.Red ) ) SendMessage( ProgressBar1.Handle, PBM_SETBARCOLOR, 0I, New COLORREF(Color.Yellow) ) End Sub
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.