Click here to Skip to main content
15,881,173 members
Articles / Multimedia / GDI+
Article

Creating some cool buttons and groupboxes

Rate me:
Please Sign up or sign in to vote.
3.26/5 (37 votes)
2 Sep 20041 min read 78.1K   4.3K   66   10
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


Written By
Web Developer
India India
My mail ID is shouvik@lycos.com

Comments and Discussions

 
QuestionI want to get permission to use your Code Pin
Member 139991158-Jul-19 17:09
Member 139991158-Jul-19 17:09 
GeneralThanks much Pin
projectileboy28-May-05 19:23
projectileboy28-May-05 19:23 
GeneralColor Scheme Pin
Terence Wallace18-Apr-05 15:08
Terence Wallace18-Apr-05 15:08 
GeneralRe: Color Scheme Pin
Shouvik18-Apr-05 18:29
Shouvik18-Apr-05 18:29 
GeneralOpen UserControl Problem .... Pin
Inquire2you6-Oct-04 5:31
Inquire2you6-Oct-04 5:31 
GeneralRe: Open UserControl Problem .... Pin
Shouvik18-Apr-05 18:31
Shouvik18-Apr-05 18:31 
GeneralArticle Content Pin
Richard Parsons27-Aug-04 3:20
Richard Parsons27-Aug-04 3:20 
GeneralRe: Article Content Pin
Richard Parsons30-Aug-04 2:58
Richard Parsons30-Aug-04 2:58 
GeneralNothing much in the article Pin
J Hurrell27-Aug-04 2:23
J Hurrell27-Aug-04 2:23 
GeneralRe: Nothing much in the article Pin
T1TAN26-Oct-07 0:14
T1TAN26-Oct-07 0:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.