Share via


ColorTranslator.ToOle(Color) Methode

Definition

Übersetzt die angegebene Color-Struktur in eine OLE-Farbe.

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

Parameter

c
Color

Die zu übersetzende Color-Struktur.

Gibt zurück

Der OLE-Farbwert.

Beispiele

Das folgende Beispiel ist für die Verwendung mit Windows Forms konzipiert und erfordert PaintEventArgse, was ein Parameter des Paint Ereignishandlers ist. Der Code übersetzt eine Color Struktur in eine ganze Zahl, die eine OLE-Farbe darstellt, und zeigt dann ein Meldungsfeld mit der resultierenden Zeichenfolge an.

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

Gilt für: