So I've got a borderless form and I need it to be re-sizable (by clicking any of the 4 sides or the corners). To clarify, I want my form to be borderless like the default sticky notes in Windows 7.
I've got it to work (on bottom right corner only for now) by using the code provided by Julien Lebosquain on this post:
Resize borderless window on bottom right corner
However, I would really like to display the drag gripper image on the bottom right corner. In his post, Julien mentioned this regarding the gripper:
you can initialize a new
VisualStyleRenderer(VisualStyleElement.Status.Gripper.Normal) and
use itsPaintBackground()
method.
I'm not sure how to go about doing this within my form. Can someone point me in the right direction?
Thank you.
So after reading up on it a bit here: http://msdn.microsoft.com/en-us/library/system.windows.forms.visualstyles.visualstyleelement.status.gripper.normal.aspx, I've got the solution.
First override the OnPaint()
event for the form.
protected override void OnPaint(PaintEventArgs e) {
base.OnPaint(e);
DrawGripper(e);
}
And the method that does the drawing.
public void DrawGripper(PaintEventArgs e) {
if (VisualStyleRenderer.IsElementDefined(
VisualStyleElement.Status.Gripper.Normal)) {
VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Status.Gripper.Normal);
Rectangle rectangle1 = new Rectangle((Width) - 18, (Height) - 20, 20, 20);
renderer.DrawBackground(e.Graphics, rectangle1);
}
}
See this post at CodeProject http://www.codeproject.com/KB/cs/borderlessform.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With