ColorTranslator.FromWin32(Int32) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将 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
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈