次の方法で共有


ColorTranslator.FromWin32 メソッド

Windows カラー値を GDI+ Color 構造体に変換します。

Public Shared Function FromWin32( _
   ByVal win32Color As Integer _) As Color
[C#]
public static Color FromWin32(intwin32Color);
[C++]
public: static Color FromWin32(intwin32Color);
[JScript]
public static function FromWin32(
   win32Color : int) : Color;

パラメータ

  • win32Color
    変換対象の Windows カラー。

戻り値

変換した Windows カラーを表す Color 構造体。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードでは、Windows カラー値を Color 構造体に変換し、その色で四角形を塗りつぶします。

 
Public Sub FromWin32_Example(e As PaintEventArgs)
' Create an integer representation of a Win32 color.
Dim winColor As Integer = &HA000
' Translate winColor to a GDI+ Color structure.
Dim myColor As Color = ColorTranslator.FromWin32(winColor)
' Fill a rectangle with myColor.
e.Graphics.FillRectangle(New SolidBrush(myColor), 0, 0, 100, 100)
End Sub
        
[C#] 
public void FromWin32_Example(PaintEventArgs e)
{
// Create an integer representation of a Windows color.
int winColor = 0xA000;
// Translate winColor to a GDI+ Color structure.
Color myColor = ColorTranslator.FromWin32(winColor);
// Fill a rectangle with myColor.
e.Graphics.FillRectangle(
new SolidBrush(myColor),
0,
0,
100,
100);
}
        

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

ColorTranslator クラス | ColorTranslator メンバ | System.Drawing 名前空間