语言

ColorTranslator.FromOle(Int32) 方法

定义

将 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

适用于