Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Creating some cool buttons and groupboxes

0.00/5 (No votes)
2 Sep 2004 1  
Using GDI+ functions to add cool stuff.

Sample Image - testSampleScreen.jpg

Introduction

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here