ControlPaint::DrawCaptionButton Method (Graphics^, Rectangle, 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,
	Rectangle rectangle,
	CaptionButton button,
	ButtonState state
)

Parameters

graphics
Type: System.Drawing::Graphics^

The Graphics to draw on.

rectangle
Type: System.Drawing::Rectangle

The Rectangle that represents the dimensions of the caption button.

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 ControlPaint::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: