Share via


ColorTranslator.ToOle(Color) 方法

定義

將指定的 Color 結構轉換為 OLE 色彩。

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

參數

c
Color

要轉換的 Color 結構。

傳回

OLE 色彩值。

範例

下列範例是設計來搭配 Windows Forms 使用,而且需要 PaintEventArgse,這是事件處理程序的參數Paint。 程序代碼會將 Color 結構轉譯為代表 OLE 色彩的整數,然後顯示含有結果字串的消息框。

public:
   void ToOle_Example( PaintEventArgs^ /*e*/ )
   {
      // Create an instance of a Color structure.
      Color myColor = Color::Red;

      // Translate myColor to an OLE color.
      int oleColor = ColorTranslator::ToOle( myColor );

      // Show a message box with the value of oleColor.
      MessageBox::Show( oleColor.ToString() );
   }
public void ToOle_Example(PaintEventArgs e)
{
   // Create an instance of a Color structure.
    Color myColor = Color.Red;
             
    // Translate myColor to an OLE color.
    int oleColor = ColorTranslator.ToOle(myColor);
             
    // Show a message box with the value of oleColor.
    MessageBox.Show(oleColor.ToString());
}
Public Sub ToOle_Example(ByVal e As PaintEventArgs)

    ' Create an instance of a Color structure.
    Dim myColor As Color = Color.Green

    ' Translate myColor to an OLE color.
    Dim oleColor As Integer = ColorTranslator.ToOle(myColor)

    ' Show a message box with the value of htmlColor.
    MessageBox.Show(oleColor.ToString())
End Sub

適用於