Sdílet prostřednictvím


ColorTranslator.ToOle(Color) Metoda

Definice

Přeloží zadanou Color strukturu na barvu 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

Parametry

c
Color

Struktura Color , která se má přeložit.

Návraty

Hodnota barvy OLE.

Příklady

Následující příklad je navržený pro použití s model Windows Forms a vyžaduje PaintEventArgse, což je parametr obslužné rutiny Paint události. Kód přeloží Color strukturu na celé číslo, které představuje barvu OLE, a poté zobrazí okno se zprávou s výsledným řetězcem.

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

Platí pro