语言

ControlPaint.DrawFocusRectangle 方法

定义

绘制焦点矩形。

重载

名称 说明
DrawFocusRectangle(Graphics, Rectangle, Color, Color)

在指定的图形图面和指定边界内绘制焦点矩形。

DrawFocusRectangle(Graphics, Rectangle)

在指定的图形图面和指定边界内绘制焦点矩形。

DrawFocusRectangle(Graphics, Rectangle, Color, Color)

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

在指定的图形图面和指定边界内绘制焦点矩形。

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)

参数

graphics
Graphics

要 Graphics 绘制的。

rectangle
Rectangle

表示 Rectangle 抓取手柄字形的尺寸。

foreColor
Color

这是 Color 要为其绘制焦点矩形的对象的前景色。

backColor
Color

这是 Color 要绘制焦点矩形的对象的背景色。

示例

下面的代码示例演示如何使用 DrawFocusRectangle 方法和 Control.Handle 属性。 若要运行此示例,请将以下代码粘贴到窗体中。 将两个命名 Button1 按钮和 Button2 添加到窗体,并确保所有事件都连接到其事件处理程序。

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

注解

焦点矩形是一个虚线矩形,Windows 用于指示哪些控件具有当前键盘焦点。

适用于

DrawFocusRectangle(Graphics, Rectangle)

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

在指定的图形图面和指定边界内绘制焦点矩形。

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)

参数

graphics
Graphics

要 Graphics 绘制的。

rectangle
Rectangle

表示 Rectangle 抓取手柄字形的尺寸。

示例

下面的代码示例演示如何使用 DrawFocusRectangle 方法和 Control.Handle 属性。 若要运行此示例,请将以下代码粘贴到窗体中。 添加两个命名Button1Button2按钮和窗体,并确保所有事件都连接到其事件处理程序。

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

注解

焦点矩形是一个虚线矩形,Windows 用于指示哪些控件具有当前键盘焦点。

适用于