Freigeben über


ColorTranslator.ToWin32-Methode

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

Namespace: System.Drawing
Assembly: System.Drawing (in system.drawing.dll)

Syntax

'Declaration
Public Shared Function ToWin32 ( _
    c As Color _
) As Integer
'Usage
Dim c As Color
Dim returnValue As Integer

returnValue = ColorTranslator.ToWin32(c)
public static int ToWin32 (
    Color c
)
public:
static int ToWin32 (
    Color c
)
public static int ToWin32 (
    Color c
)
public static function ToWin32 (
    c : Color
) : int

Parameter

  • c
    Die zu übersetzende Color-Struktur.

Rückgabewert

Der Windows-Farbwert.

Beispiel

Das folgende Beispiel ist für die Verwendung mit Windows Forms vorgesehen und erfordert PaintEventArgse, wobei es sich um einen Parameter des Paint-Ereignishandlers handelt. Der Code übersetzt eine Color-Struktur in eine ganze Zahl, die eine Windows-Farbe darstellt, und zeigt anschließend ein Meldungsfeld mit der resultierenden Zeichenfolge an.

Public Sub ToWin32_Example(ByVal e As PaintEventArgs)

    ' Create an instance of a Color structure.
    Dim myColor As Color = Color.Red

    ' Translate myColor to an OLE color.
    Dim winColor As Integer = ColorTranslator.ToWin32(myColor)

    ' Show a message box with the value of winColor.
    MessageBox.Show(winColor)
End Sub
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());
}
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() );
   }
public void ToWin32_Example(PaintEventArgs e)
{
    // Create an instance of a Color structure.
    Color myColor = Color.get_Red();

    // Translate myColor to an OLE color.
    int winColor = ColorTranslator.ToWin32(myColor);

    // Show a message box with the value of winColor.
    MessageBox.Show(System.Convert.ToString(winColor));
} //ToWin32_Example

Plattformen

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

ColorTranslator-Klasse
ColorTranslator-Member
System.Drawing-Namespace