ControlPaint::DrawCaptionButton Method (Graphics^, Int32, Int32, Int32, Int32, CaptionButton, ButtonState)

 

Draws the specified caption button control in the specified state, on the specified graphics surface, and within the specified bounds.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public:
static void DrawCaptionButton(
	Graphics^ graphics,
	int x,
	int y,
	int width,
	int height,
	CaptionButton button,
	ButtonState state
)

Parameters

graphics
Type: System.Drawing::Graphics^

The Graphics to draw on.

x
Type: System::Int32

The x-coordinate of the top left of the drawing rectangle.

y
Type: System::Int32

The y-coordinate of the top left of the drawing rectangle.

width
Type: System::Int32

The width of the drawing rectangle.

height
Type: System::Int32

The height of the drawing rectangle.

button
Type: System.Windows.Forms::CaptionButton

One of the CaptionButton values that specifies the type of caption button to draw.

state
Type: System.Windows.Forms::ButtonState

A bitwise combination of the ButtonState values that specifies the state to draw the button in.

The following code example demonstrates the use of the DrawCaptionButton method and the CaptionButton enumeration. To run this example, paste the following code in a form containing a Button named Button1. The form should import the System.Windows.Forms and System.Drawing namespaces. Ensure the button's Paint event is associated with the event handler in this example.

// Handle the Button1 object's Paint Event to create a CaptionButton.
void Button1_Paint( Object^ /*sender*/, PaintEventArgs^ e )
{

   // Draw a CaptionButton control using the ClientRectangle 
   // property of Button1. Make the button a Help button 
   // with a normal state.
   ControlPaint::DrawCaptionButton( e->Graphics, Button1->ClientRectangle, CaptionButton::Help, ButtonState::Normal );
}

.NET Framework
Available since 1.1
Return to top
Show: