ControlPaint.DrawFocusRectangle 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.
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)
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
- 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)
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
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
Pripomienky
https://aka.ms/ContentUserFeedback.
Pripravujeme: V priebehu roka 2024 postupne zrušíme službu Problémy v službe GitHub ako mechanizmus pripomienok týkajúcich sa obsahu a nahradíme ju novým systémom pripomienok. Ďalšie informácie nájdete na stránke:Odoslať a zobraziť pripomienky pre