ColorTranslator.ToWin32(Color) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将指定的 Color 结构翻译成 Windows 颜色。
public:
static int ToWin32(System::Drawing::Color c);
public static int ToWin32 (System.Drawing.Color c);
static member ToWin32 : System.Drawing.Color -> int
Public Shared Function ToWin32 (c As Color) As Integer
参数
返回
Windows 颜色值。
示例
以下示例旨在与 Windows 窗体 一起使用,它需要 PaintEventArgse
,这是事件处理程序的参数Paint。 该代码将 Color 结构转换为表示 Windows 颜色的整数,然后显示包含生成的字符串的消息框。
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 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
适用于
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈