共用方式為


ControlPaint.DrawFocusRectangle 方法

定義

繪製焦點矩形 (Focus Rectangle)。

多載

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 屬性。 若要執行此範例,請將下列程式碼貼到表單中。 將名為 和 Button2 的兩個 Button1 按鈕新增至表單,並確定所有事件都已連線到其事件處理常式。

// 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 屬性。 若要執行此範例,請將下列程式碼貼到表單中。 將名為 和 Button2 的兩個 Button1 按鈕新增至表單,並確定所有事件都已連線到其事件處理常式。

// 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 用來指出哪些控制項具有目前的鍵盤焦點。

適用於