ControlPaint::DrawReversibleLine Method (Point, Point, Color)
Draws a reversible line on the screen within the specified starting and ending points and with the specified background color.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
public: [UIPermissionAttribute(SecurityAction::LinkDemand, Window = UIPermissionWindow::AllWindows)] static void DrawReversibleLine( Point start, Point end, Color backColor )
Parameters
- start
-
Type:
System.Drawing::Point
The starting Point of the line, in screen coordinates.
- end
-
Type:
System.Drawing::Point
The ending Point of the line, in screen coordinates.
- backColor
-
Type:
System.Drawing::Color
The Color of the background behind the line.
The backColor parameter is used to calculate the fill color of the line so that it is always visible against the background.
The results of this method can be reversed by drawing the same line again. Drawing a line using this method is similar to inverting a region of the screen, except that it provides better performance for a wider variety of colors.
The following code example demonstrates using the ControlPaint::DrawReversibleLine and Control::PointToScreen methods. To run the example, paste the following code in a form. Add a button named Button3 to the form and ensure all events are connected to their event handlers.
// When the mouse hovers over Button3, two reversible lines are // drawn using the corner coordinates of Button3, which are first // converted to screen coordinates. void Button3_MouseHover( Object^ /*sender*/, System::EventArgs^ /*e*/ ) { ControlPaint::DrawReversibleLine( Button3->PointToScreen( Point(0,0) ), Button3->PointToScreen( Point(Button3->ClientRectangle.Right,Button3->ClientRectangle.Bottom) ), SystemColors::Control ); ControlPaint::DrawReversibleLine( Button3->PointToScreen( Point(Button3->ClientRectangle.Right,Button3->ClientRectangle.Top) ), Button3->PointToScreen( 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. void Button3_MouseLeave( Object^ /*sender*/, System::EventArgs^ /*e*/ ) { ControlPaint::DrawReversibleLine( Button3->PointToScreen( Point(0,0) ), Button3->PointToScreen( Point(Button3->ClientRectangle.Right,Button3->ClientRectangle.Bottom) ), SystemColors::Control ); ControlPaint::DrawReversibleLine( Button3->PointToScreen( Point(Button3->ClientRectangle.Right,Button3->ClientRectangle.Top) ), Button3->PointToScreen( Point(Button3->ClientRectangle.Left,Button3->ClientRectangle.Bottom) ), SystemColors::Control ); }
Available since 1.1