![ctrl paint for glass on chemglass ctrl paint for glass on chemglass](https://i2.wp.com/glasswithapast.com/wp-content/uploads/2014/01/redpaisley.gif)
To simulate drawing over the form's borders, you would need to turn off the form's border and draw it with the component-and re-implement all of the lost functionality. It cannot draw over the form's title bar or borders, and it cannot draw between forms. The component can only draw within a form's client area. One solution to this problem is to turn off the control's border and draw it using the component. Some controls include a border that is not part of their client area, so the component cannot draw over the border. The component can only draw over a control's client area.
![ctrl paint for glass on chemglass ctrl paint for glass on chemglass](https://chemglass.com/images/thumbs/0011478_digital-magnetic-hot-plate-with-timer-bundles-with-tri-block-reaction-blocks-vials.jpeg)
It may be possible to use text box controls from a third party, but I have not tested any of them. The TextBox control does not fire a Paint event, so the component cannot draw over TextBox controls. The component responds to each control's Paint event. Calling the component's Invalidate() method will invalidate the form and each of the form's controls. Just draw using Coordinates(control) instead of control.Location.īecause the graphical overlay can be drawn over all of the form's controls, redrawing it requires the entire form to be invalidated. The Coordinates() method converts the control's location to form-relative coordinates. So, to make control-relative drawing easier, I have added an extension method called Coordinates() to the class. This approach makes it difficult to draw relative to the controls, however. Just draw as if you're drawing within the form's client area. Then, the component attaches its Control_Paint event handler to the Paint event for each of the owner form's controls (including the owner form itself).Īs each control is repainted, the component handles the Paint event, transforms the coordinates of the e.Graphics object, then fires its own Paint event which will be handled by the form's graphicalOverlay1_Paint event handler.īecause the e.Graphics object received by graphicalOverlay1_Paint() has been transformed to use the form's coordinate system, all of the drawing logic is form-relative. When the graphicalOverlay1.Owner property is set, the component connects its Form_Resize event handler to the owner form's Resize event. The component contains the following event handlers: using (Pen pen = new Pen(Color.Blue, 3))Į.Graphics.DrawEllipse(pen, pictureBox1.Coordinates())
![ctrl paint for glass on chemglass ctrl paint for glass on chemglass](https://images-na.ssl-images-amazon.com/images/I/61Qotq1x1fL._AC_.jpg)
To draw relative to a control, use the Coordinates method.