ColorTranslator.ToWin32(Color) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Translates the specified Color structure to a Windows color.
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
Parameters
Returns
The Windows color value.
Examples
The following example is designed for use with Windows Forms, and it requires PaintEventArgs e
, which is a parameter of the Paint event handler. The code translates a Color structure to an integer that represents a Windows color, and then shows a message box with the resulting string.
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
Applies to
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
.NET