This is an article on how to create buttons and groupboxes of different shapes using different GDI+ functions.
This example uses
GraphicsPath object and others. To create elongated buttons and round cornered groupboxes, we are using a
GrahicsPath object and adding a semicircle using
AddArc to the left and right, and a rectangle in between for the elongated shape. To create a trapezium shape for the
Labels, I have used the client rectangle and created a polygon with points to the three corners of the client rectangle and the top right corner. I have reduced the width by 20 pixels. For the drop shadow labels, I have got shadow colors by using alpha index of black colors, and written the text as many times as the shadow length is specified, increasing the left and top position by one pixel for each iteration. Also, I used the control's
Region property to specify non regular shapes, i.e., non rectangular shape of the control.
Here, we use
LinearGradientBrush to draw gradients and use
GraphicsPath to get non rectangular shape. The color scheme property of the controls help to change different colors of the controls through the interfaces. The
OnPaint method calls different methods to draw the control in that way.