ColorTranslator.FromWin32 Method (Int32)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Translates a Windows color value to a GDI+ Color structure.

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

public static Color FromWin32(
	int win32Color


Type: System.Int32

The Windows color to translate.

Return Value

Type: System.Drawing.Color

The Color structure that represents the translated Windows color.

The following example is designed for use with Windows Forms, and it requires PaintEventArgse, which is a parameter of the Paint event handler. The code translates a Windows color value to a Color structure, and then uses that color to fill a rectangle.

public void FromWin32_Example(PaintEventArgs e)
    // Create an integer representation of a Windows color.
    int winColor = 0xA000;

    // Translate winColor to a GDI+ Color structure.
    Color myColor = ColorTranslator.FromWin32(winColor);

    // Fill a rectangle with myColor.
    e.Graphics.FillRectangle( new SolidBrush(myColor), 0, 0, 
        100, 100);


.NET Framework
Available since 1.1
Return to top