ControlPaint.DrawFocusRectangle Metoda

Definicja

Rysuje prostokąt fokusu.

Przeciążenia

DrawFocusRectangle(Graphics, Rectangle, Color, Color)

Rysuje prostokąt fokusu na określonej powierzchni grafiki i w określonych granicach.

DrawFocusRectangle(Graphics, Rectangle)

Rysuje prostokąt fokusu na określonej powierzchni grafiki i w określonych granicach.

DrawFocusRectangle(Graphics, Rectangle, Color, Color)

Rysuje prostokąt fokusu na określonej powierzchni grafiki i w określonych granicach.

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)

Parametry

graphics
Graphics

Narysować Graphics .

rectangle
Rectangle

Element Rectangle reprezentujący wymiary uchwytu chwytania.

foreColor
Color

Jest Color to kolor pierwszego planu obiektu do rysowania prostokąta fokusu.

backColor
Color

Jest Color to kolor tła obiektu, na który ma być narysowy prostokąt fokusu.

Przykłady

Poniższy przykład kodu pokazuje użycie DrawFocusRectangle metody i Control.Handle właściwości. Aby uruchomić ten przykład, wklej następujący kod w formularzu. Dodaj dwa przyciski o nazwie Button1 i Button2 do formularza i upewnij się, że wszystkie zdarzenia są połączone z ich procedurami obsługi zdarzeń.

// 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

Uwagi

Prostokąt fokusu to prostokąt kropkowany, który Windows używa do wskazania, która kontrolka ma bieżący fokus klawiatury.

Dotyczy

DrawFocusRectangle(Graphics, Rectangle)

Rysuje prostokąt fokusu na określonej powierzchni grafiki i w określonych granicach.

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)

Parametry

graphics
Graphics

Narysować Graphics .

rectangle
Rectangle

Element Rectangle reprezentujący wymiary uchwytu chwytania.

Przykłady

Poniższy przykład kodu pokazuje użycie DrawFocusRectangle metody i Control.Handle właściwości. Aby uruchomić ten przykład, wklej następujący kod w formularzu. Dodaj dwa przyciski o nazwie Button1 i Button2 do formularza i upewnij się, że wszystkie zdarzenia są połączone z ich procedurami obsługi zdarzeń.

// 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

Uwagi

Prostokąt fokusu to prostokąt kropkowany, który Windows używa do wskazania, która kontrolka ma bieżący fokus klawiatury.

Dotyczy