ColorTranslator.FromOle(Int32) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將 OLE 色彩值轉換成 GDI+ Color 結構。
public:
static System::Drawing::Color FromOle(int oleColor);
public static System.Drawing.Color FromOle(int oleColor);
static member FromOle : int -> System.Drawing.Color
Public Shared Function FromOle (oleColor As Integer) As Color
參數
- oleColor
- Int32
要翻譯 OLE 顏色。
傳回
Color代表翻譯後 OLE 顏色的結構。
範例
以下範例是為 Windows 表單設計,並需要 PaintEventArgse,這是事件處理器的 Paint 參數。 程式碼會將 OLE 的顏色值轉換成結構 Color ,然後用該顏色填滿一個矩形。
public:
void FromOle_Example( PaintEventArgs^ e )
{
// Create an integer representation of an OLE color.
int oleColor = 0xFF00;
// Translate oleColor to a GDI+ Color structure.
Color myColor = ColorTranslator::FromOle( oleColor );
// Fill a rectangle with myColor.
e->Graphics->FillRectangle( gcnew SolidBrush( myColor ), 0, 0, 100, 100 );
}
public void FromOle_Example(PaintEventArgs e)
{
// Create an integer representation of an OLE color.
int oleColor = 0xFF00;
// Translate oleColor to a GDI+ Color structure.
Color myColor = ColorTranslator.FromOle(oleColor);
// Fill a rectangle with myColor.
e.Graphics.FillRectangle( new SolidBrush(myColor), 0, 0,
100, 100);
}
Public Sub FromOle_Example(ByVal e As PaintEventArgs)
' Create an integer representation of an HTML color.
Dim oleColor As Integer = &HFF00
' Translate oleColor to a GDI+ Color structure.
Dim myColor As Color = ColorTranslator.FromOle(oleColor)
' Fill a rectangle with myColor.
e.Graphics.FillRectangle(New SolidBrush(myColor), 0, 0, 100, 100)
End Sub