Drawing a gripper in a borderless form
.net, c#, user-interface, winforms
Solution
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);
}
}
Problem
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 its `PaintBackground()` method. I'm not sure how to go about doing this within my form. Can someone point me in the right direction? Thank you.