Bewerken

Delen via


ControlPaint.DrawFocusRectangle Method

Definition

Draws a focus rectangle.

Overloads

DrawFocusRectangle(Graphics, Rectangle, Color, Color)

Draws a focus rectangle on the specified graphics surface and within the specified bounds.

DrawFocusRectangle(Graphics, Rectangle)

Draws a focus rectangle on the specified graphics surface and within the specified bounds.

DrawFocusRectangle(Graphics, Rectangle, Color, Color)

Source:
ControlPaint.cs
Source:
ControlPaint.cs
Source:
ControlPaint.cs

Draws a focus rectangle on the specified graphics surface and within the specified bounds.

public:
 static void DrawFocusRectangle(System::Drawing::Graphics ^ graphics, System::Drawing::Rectangle rectangle, System::Drawing::Color foreColor, System::Drawing::Color backColor);
public static void DrawFocusRectangle (System.Drawing.Graphics graphics, System.Drawing.Rectangle rectangle, System.Drawing.Color foreColor, System.Drawing.Color backColor);
static member DrawFocusRectangle : System.Drawing.Graphics * System.Drawing.Rectangle * System.Drawing.Color * System.Drawing.Color -> unit
Public Shared Sub DrawFocusRectangle (graphics As Graphics, rectangle As Rectangle, foreColor As Color, backColor As Color)

Parameters

graphics
Graphics

The Graphics to draw on.

rectangle
Rectangle

The Rectangle that represents the dimensions of the grab handle glyph.

foreColor
Color

The Color that is the foreground color of the object to draw the focus rectangle on.

backColor
Color

The Color that is the background color of the object to draw the focus rectangle on.

Examples

The following code example demonstrates using the DrawFocusRectangle method and the Control.Handle property. To run this example, paste the following code in a form. Add two buttons named Button1 and Button2 to the form and ensure all events are connected to their event handlers.

// This method draws a focus rectangle on Button2 using the 
// handle and client rectangle of Button2.
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   ControlPaint::DrawFocusRectangle( Graphics::FromHwnd( Button2->Handle ), Button2->ClientRectangle );
}
// This method draws a focus rectangle on Button2 using the 
// handle and client rectangle of Button2.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
    ControlPaint.DrawFocusRectangle(Graphics.FromHwnd(Button2.Handle), 
        Button2.ClientRectangle);
}
' This method draws a focus rectangle on Button2 using the 
' handle and client rectangle of Button2.
Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    ControlPaint.DrawFocusRectangle(Graphics.FromHwnd(Button2.Handle), _
    Button2.ClientRectangle)
End Sub

Remarks

A focus rectangle is a dotted rectangle that Windows uses to indicate what control has the current keyboard focus.

Applies to

DrawFocusRectangle(Graphics, Rectangle)

Source:
ControlPaint.cs
Source:
ControlPaint.cs
Source:
ControlPaint.cs

Draws a focus rectangle on the specified graphics surface and within the specified bounds.

public:
 static void DrawFocusRectangle(System::Drawing::Graphics ^ graphics, System::Drawing::Rectangle rectangle);
public static void DrawFocusRectangle (System.Drawing.Graphics graphics, System.Drawing.Rectangle rectangle);
static member DrawFocusRectangle : System.Drawing.Graphics * System.Drawing.Rectangle -> unit
Public Shared Sub DrawFocusRectangle (graphics As Graphics, rectangle As Rectangle)

Parameters

graphics
Graphics

The Graphics to draw on.

rectangle
Rectangle

The Rectangle that represents the dimensions of the grab handle glyph.

Examples

The following code example demonstrates using the DrawFocusRectangle method and the Control.Handle property. To run this example, paste the following code in a form. Add two buttons named Button1 and Button2 to the form and ensure all events are connected to their event handlers.

// This method draws a focus rectangle on Button2 using the 
// handle and client rectangle of Button2.
void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
{
   ControlPaint::DrawFocusRectangle( Graphics::FromHwnd( Button2->Handle ), Button2->ClientRectangle );
}
// This method draws a focus rectangle on Button2 using the 
// handle and client rectangle of Button2.
private void Button1_Click(System.Object sender, System.EventArgs e)
{
    ControlPaint.DrawFocusRectangle(Graphics.FromHwnd(Button2.Handle), 
        Button2.ClientRectangle);
}
' This method draws a focus rectangle on Button2 using the 
' handle and client rectangle of Button2.
Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    ControlPaint.DrawFocusRectangle(Graphics.FromHwnd(Button2.Handle), _
    Button2.ClientRectangle)
End Sub

Remarks

A focus rectangle is a dotted rectangle that Windows uses to indicate what control has the current keyboard focus.

Applies to