ControlPaint.DrawFocusRectangle 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
繪製焦點矩形 (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)
參數
範例
下列程式碼範例示範如何使用 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)
參數
範例
下列程式碼範例示範如何使用 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 用來指出哪些控制項具有目前的鍵盤焦點。