次の方法で共有


ControlPaint.DrawReversibleLine メソッド

画面の反転できる線を、指定した開始点と指定したエンド ポイントの間に、指定した背景色を使用して描画します。

Public Shared Sub DrawReversibleLine( _
   ByVal start As Point, _   ByVal end As Point, _   ByVal backColor As Color _)
[C#]
public static void DrawReversibleLine(Pointstart,Pointend,ColorbackColor);
[C++]
public: static void DrawReversibleLine(Pointstart,Pointend,ColorbackColor);
[JScript]
public static function DrawReversibleLine(
   start : Point,end : Point,backColor : Color);

パラメータ

  • start
    画面座標の線の始点となる Point
  • end
    画面座標の線のエンド ポイントとなる Point
  • backColor
    線の背景の Color

解説

backColor パラメータを使用して、線が背景に対して常に表示されるように、線の塗りつぶし色を計算します。

このメソッドの結果、同じ線を再び描画することによって反転できます。このメソッドを使用して線を描画することは、より多くの色に対してより優れたパフォーマンスが提供されることを除いて、画面の領域を反転することに似ています。

使用例

[Visual Basic, C#] DrawReversibleLine メソッドと PointToScreen メソッドを使用するコード例を次に示します。この例を実行するには、次のコードをフォームに貼り付けます。そして、Button3 という名前のボタンを追加し、すべてのイベントを必ずそれぞれのイベント処理メソッドに関連付けるようにします。

 
' When the mouse hovers over Button3, two reversible lines are drawn
' using the corner coordinates of Button3, which are first 
' converted to screen coordinates.
Private Sub Button3_MouseHover(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button3.MouseHover

    ControlPaint.DrawReversibleLine(Button3.PointToScreen(New Point(0, 0)), _
    Button3.PointToScreen(New Point(Button3.ClientRectangle.Right, _
        Button3.ClientRectangle.Bottom)), SystemColors.Control)
    ControlPaint.DrawReversibleLine(Button3.PointToScreen( _
        New Point(Button3.ClientRectangle.Right, Button3.ClientRectangle.Top)), _
       Button3.PointToScreen(New Point _
            (Button1.ClientRectangle.Left, Button3.ClientRectangle.Bottom)), _
            SystemColors.Control)
End Sub

' When the mouse moves from Button3, the reversible lines are 
' erased by using the same coordinates as are used in the
' Button3_MouseHover method.
Private Sub Button3_MouseLeave(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles Button3.MouseLeave

    ControlPaint.DrawReversibleLine(Button3.PointToScreen(New Point(0, 0)), _
    Button3.PointToScreen(New Point(Button3.ClientRectangle.Right, _
        Button3.ClientRectangle.Bottom)), SystemColors.Control)
    ControlPaint.DrawReversibleLine(Button3.PointToScreen( _
        New Point(Button3.ClientRectangle.Right, Button3.ClientRectangle.Top)), _
       Button3.PointToScreen(New Point(Button3.ClientRectangle.Left, _
       Button3.ClientRectangle.Bottom)), SystemColors.Control)
End Sub

[C#] 
// When the mouse hovers over Button3, two reversible lines are 
// drawn using the corner coordinates of Button3, which are first 
// converted to screen coordinates.
private void Button3_MouseHover(object sender, System.EventArgs e)
{
    ControlPaint.DrawReversibleLine(Button3.PointToScreen(
        new Point(0, 0)), Button3.PointToScreen(
        new Point(Button3.ClientRectangle.Right, 
        Button3.ClientRectangle.Bottom)), SystemColors.Control);
    
    ControlPaint.DrawReversibleLine(Button3.PointToScreen(
        new Point(Button3.ClientRectangle.Right, 
        Button3.ClientRectangle.Top)), 
        Button3.PointToScreen(new Point(Button1.ClientRectangle.Left, 
        Button3.ClientRectangle.Bottom)), SystemColors.Control);
}

// When the mouse moves from Button3, the reversible lines are erased by
// using the same coordinates as are used in the Button3_MouseHover method.
private void Button3_MouseLeave(object sender, System.EventArgs e)
{
    ControlPaint.DrawReversibleLine(Button3.PointToScreen(
        new Point(0, 0)), Button3.PointToScreen(
        new Point(Button3.ClientRectangle.Right, 
        Button3.ClientRectangle.Bottom)), SystemColors.Control);
    
    ControlPaint.DrawReversibleLine(Button3.PointToScreen(
        new Point(Button3.ClientRectangle.Right, 
        Button3.ClientRectangle.Top)), 
        Button3.PointToScreen(new Point(Button3.ClientRectangle.Left,
        Button3.ClientRectangle.Bottom)), SystemColors.Control);
}

[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

ControlPaint クラス | ControlPaint メンバ | System.Windows.Forms 名前空間 | FrameStyle