ControlPaint.DrawFocusRectangle Método

Definición

Dibuja un rectángulo de foco.Draws a focus rectangle.

Sobrecargas

DrawFocusRectangle(Graphics, Rectangle, Color, Color)

Dibuja un rectángulo de foco en la superficie gráfica especificada y dentro de los límites especificados.Draws a focus rectangle on the specified graphics surface and within the specified bounds.

DrawFocusRectangle(Graphics, Rectangle)

Dibuja un rectángulo de foco en la superficie gráfica especificada y dentro de los límites especificados.Draws a focus rectangle on the specified graphics surface and within the specified bounds.

DrawFocusRectangle(Graphics, Rectangle, Color, Color)

Dibuja un rectángulo de foco en la superficie gráfica especificada y dentro de los límites especificados.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)

Parámetros

graphics
Graphics

Graphics donde se va a dibujar.The Graphics to draw on.

rectangle
Rectangle

Rectangle que representa las dimensiones del glifo de controlador de arrastre.The Rectangle that represents the dimensions of the grab handle glyph.

foreColor
Color

Color que es el color de primer plano del objeto donde se va a dibujar el rectángulo de foco.The Color that is the foreground color of the object to draw the focus rectangle on.

backColor
Color

Color que es el color de fondo del objeto donde se va a dibujar el rectángulo de foco.The Color that is the background color of the object to draw the focus rectangle on.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el DrawFocusRectangle método y la Control.Handle propiedad.The following code example demonstrates using the DrawFocusRectangle method and the Control.Handle property. Para ejecutar este ejemplo, pegue el código siguiente en un formulario.To run this example, paste the following code in a form. Agregue dos botones denominados Button1 y BUTTON2 al formulario y asegúrese de que todos los eventos estén conectados a sus controladores de eventos.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

Comentarios

Un rectángulo de foco es un rectángulo punteado que Windows usa para indicar qué control tiene el foco de teclado actual.A focus rectangle is a dotted rectangle that Windows uses to indicate what control has the current keyboard focus.

Se aplica a

DrawFocusRectangle(Graphics, Rectangle)

Dibuja un rectángulo de foco en la superficie gráfica especificada y dentro de los límites especificados.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)

Parámetros

graphics
Graphics

Graphics donde se va a dibujar.The Graphics to draw on.

rectangle
Rectangle

Rectangle que representa las dimensiones del glifo de controlador de arrastre.The Rectangle that represents the dimensions of the grab handle glyph.

Ejemplos

En el ejemplo de código siguiente se muestra cómo usar el DrawFocusRectangle método y la Control.Handle propiedad.The following code example demonstrates using the DrawFocusRectangle method and the Control.Handle property. Para ejecutar este ejemplo, pegue el código siguiente en un formulario.To run this example, paste the following code in a form. Agregue dos botones denominados Button1 y Button2 al formulario y asegúrese de que todos los eventos estén conectados a sus controladores de eventos.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

Comentarios

Un rectángulo de foco es un rectángulo punteado que Windows usa para indicar qué control tiene el foco de teclado actual.A focus rectangle is a dotted rectangle that Windows uses to indicate what control has the current keyboard focus.

Se aplica a