語言

ControlPaint.DrawFocusRectangle 方法

定義

畫出一個焦點矩形。

多載

名稱 Description
DrawFocusRectangle(Graphics, Rectangle, Color, Color)

在指定的圖形表面及指定範圍內繪製焦點矩形。

DrawFocusRectangle(Graphics, Rectangle)

在指定的圖形表面及指定範圍內繪製焦點矩形。

DrawFocusRectangle(Graphics, Rectangle, Color, Color)

來源:
ControlPaint.cs
來源:
ControlPaint.cs
來源:
ControlPaint.cs
來源:
ControlPaint.cs
來源:
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)

來源:
ControlPaint.cs
來源:
ControlPaint.cs
來源:
ControlPaint.cs
來源:
ControlPaint.cs
來源:
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 。 要執行這個範例,請將以下程式碼貼上表單。 在表單中新增兩個名為 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 用來表示目前鍵盤焦點的控制項。

適用於