ColorTranslator.ToWin32(Color) ColorTranslator.ToWin32(Color) ColorTranslator.ToWin32(Color) ColorTranslator.ToWin32(Color) Method

定義

將指定的 Color 結構轉換為 Windows 色彩。Translates the specified Color structure to a Windows color.

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 Color Color

要轉換的 Color 結構。The Color structure to translate.

傳回

Windows 色彩值。The Windows color value.

範例

下列範例專為搭配 Windows Form 使用,而且需要PaintEventArgs e,這是參數的Paint事件處理常式。The following example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. 程式碼會將轉譯Color結構的整數,代表 Windows 色彩,然後顯示訊息方塊中,使用產生的字串。The code translates a Color structure to an integer that represents a Windows color, and then shows a message box with the resulting string.

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

適用於