ColorTranslator.ToWin32(Color) メソッド

定義

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

public:
 static int ToWin32(System::Drawing::Color c);
public static int ToWin32 (System.Drawing.Color c);
static member ToWin32 : System.Drawing.Color -> int
Public Shared Function ToWin32 (c As Color) As Integer

パラメーター

c
Color

変換対象の Color 構造体。

戻り値

Windows カラー値。

次の例は、Windows フォームで使用するように設計されており、イベント ハンドラーのPaintパラメーターである が必要PaintEventArgseです。 このコードは、構造体を Color Windows の色を表す整数に変換し、結果の文字列を含むメッセージ ボックスを表示します。

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.ToString() );
   }
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.ToString());
}
Public Sub ToWin32_Example(ByVal 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

適用対象