次の方法で共有


ColorTranslator.ToWin32 メソッド

指定した Color 構造体を Windows カラーに変換します。

Public Shared Function ToWin32( _
   ByVal c As Color _) As Integer
[C#]
public static int ToWin32(Colorc);
[C++]
public: static int ToWin32(Colorc);
[JScript]
public static function ToWin32(
   c : Color) : int;

パラメータ

  • c
    変換対象の Color 構造体。

戻り値

Windows カラー値。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e が必要です。このコードでは、 Color 構造体を Windows カラーを表す整数に変換し、メッセージ ボックスにその文字列を表示します。

 
Public Sub ToWin32_Example(e As PaintEventArgs)
' Create an instance of a Color structure.
Dim myColor As Color = Color.Red
' Translate myColor to an OLE color.
Dim winColor As Integer = ColorTranslator.ToWin32(myColor)
' Show a message box with the value of winColor.
MessageBox.Show(winColor)
End Sub
        
[C#] 
public void ToWin32_Example(PaintEventArgs e)
{
// Create an instance of a Color structure.
Color myColor = Color.Red;
// Translate myColor to an OLE color.
int winColor = ColorTranslator.ToWin32(myColor);
// Show a message box with the value of winColor.
MessageBox.Show(winColor);
}
        

[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 名前空間