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 カラー。

戻り値

変換した OLE カラーを表す Color 構造体。

次の例は、Windows フォームで使用するように設計されており、イベント ハンドラーのPaintパラメーターである が必要PaintEventArgseです。 このコードでは、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

適用対象