ColorTranslator.ToOle(Color) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將指定的 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
參數
傳回
OLE 的顏色值。
範例
以下範例是為 Windows 表單設計,並需要 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