語言

ColorTranslator.FromWin32(Int32) 方法

定義

將Windows色彩值轉換成 GDI+ Color 結構。

public:
 static System::Drawing::Color FromWin32(int win32Color);
public static System.Drawing.Color FromWin32(int win32Color);
static member FromWin32 : int -> System.Drawing.Color
Public Shared Function FromWin32 (win32Color As Integer) As Color

參數

win32Color
Int32

Windows 顏色要翻譯。

傳回

代表平移Windows色的Color結構。

範例

以下範例是為 Windows 表單設計,並需要 PaintEventArgse,這是事件處理器的 Paint 參數。 程式碼會將Windows色彩值轉換成 Color 結構,然後用該顏色填滿矩形。

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( gcnew SolidBrush( myColor ), 0, 0, 100, 100 );
   }
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);
}
Public Sub FromWin32_Example(ByVal e As PaintEventArgs)

    ' Create an integer representation of a Win32 color.
    Dim winColor As Integer = &HA000

    ' Translate winColor to a GDI+ Color structure.
    Dim myColor As Color = ColorTranslator.FromWin32(winColor)

    ' Fill a rectangle with myColor.
    e.Graphics.FillRectangle(New SolidBrush(myColor), 0, 0, 100, 100)
End Sub

適用於