ControlPaint::FillReversibleRectangle Method (Rectangle, Color)
Draws a filled, reversible rectangle on the screen.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
public: [UIPermissionAttribute(SecurityAction::LinkDemand, Window = UIPermissionWindow::AllWindows)] static void FillReversibleRectangle( Rectangle rectangle, Color backColor )
Parameters
- rectangle
-
Type:
System.Drawing::Rectangle
The Rectangle that represents the dimensions of the rectangle to fill, in screen coordinates.
- backColor
-
Type:
System.Drawing::Color
The Color of the background behind the fill.
The backColor parameter is used to calculate the fill color of the rectangle so that it is always visible against the background.
The results of this method can be reversed by drawing the same rectangle again. Drawing a rectangle 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 FillReversibleRectangle method. To run the example, paste the following code in a form. Add a button named Button2 to the form and ensure all events are connected to their event handlers.
//When the mouse hovers over Button2, its ClientRectangle is filled. void Button2_MouseHover( Object^ sender, System::EventArgs^ /*e*/ ) { Control^ senderControl = dynamic_cast<Control^>(sender); Rectangle screenRectangle = senderControl->RectangleToScreen( senderControl->ClientRectangle ); ControlPaint::FillReversibleRectangle( screenRectangle, senderControl->BackColor ); } // When the mouse leaves Button2, its ClientRectangle is cleared by // calling the FillReversibleRectangle method again. void Button2_MouseLeave( Object^ sender, System::EventArgs^ /*e*/ ) { Control^ senderControl = dynamic_cast<Control^>(sender); Rectangle screenRectangle = senderControl->RectangleToScreen( senderControl->ClientRectangle ); ControlPaint::FillReversibleRectangle( screenRectangle, senderControl->BackColor ); }
Available since 1.1