Private Const WM_USER As Integer = &H400 Private Const PBM_SETBARCOLOR As Integer = WM_USER + 9 <DllImport("User32.dll", PreserveSig:=False, CharSet:=CharSet.Auto)> Private Shared Sub SendMessage(hWnd As IntPtr, Msg As UInteger, wParam As IntPtr, lParam As IntPtr) End Sub Private Shared Sub SetBarColor(target As ProgressBar, color As Color) If Application.RenderWithVisualStyles Then Throw New InvalidOperationException("Visual スタイルが有効な状態では色の変更はできません。") End If SendMessage(target.Handle, PBM_SETBARCOLOR, IntPtr.Zero, CType(color.R Or (color.G << 8) Or (color.B << 16), IntPtr)) End Sub