ColorTranslator.ToWin32(Color) Metoda

Definicja

Tłumaczy określoną strukturę Color na kolor systemu Windows.

C#
public static int ToWin32 (System.Drawing.Color c);

Parametry

c
Color

Struktura Color do tłumaczenia.

Zwraca

Wartość koloru systemu Windows.

Przykłady

Poniższy przykład jest przeznaczony do użycia z formularzami Systemu Windows i wymaga PaintEventArgse, który jest parametrem programu obsługi zdarzeń Paint. Kod tłumaczy strukturę Color na liczbę całkowitą reprezentującą kolor systemu Windows, a następnie wyświetla pole komunikatu z wynikowym ciągiem.

C#
public void ToWin32_Example(PaintEventArgs e)
{
    // Create an instance of a Color structure.
    Color myColor = Color.Red;
             
    // Translate myColor to an OLE color.
    int winColor = ColorTranslator.ToWin32(myColor);
             
    // Show a message box with the value of winColor.
    MessageBox.Show(winColor.ToString());
}

Dotyczy

Produkt Wersje
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0