ControlPaint.DrawFocusRectangle 方法

定义

绘制聚焦框。

重载

DrawFocusRectangle(Graphics, Rectangle, Color, Color)

在指定边界内、指定的图形表面上绘制聚焦框。

DrawFocusRectangle(Graphics, Rectangle)

在指定边界内、指定的图形表面上绘制聚焦框。

DrawFocusRectangle(Graphics, Rectangle, Color, Color)

在指定边界内、指定的图形表面上绘制聚焦框。

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)

在指定边界内、指定的图形表面上绘制聚焦框。

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 属性。 若要运行此示例,请将以下代码粘贴到窗体中。 添加两个命名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用于指示具有当前键盘焦点的控件。

适用于