Click here to Skip to main content
6,594,932 members and growing! (15,306 online)
Email Password   helpLost your password?
Platforms, Frameworks & Libraries » .NET Framework » How To     Intermediate

Shaped Forms without a line of code

By Hossam Abbas

Have you ever wondered how to make a very customized form but you cannot make its graphics with code?
C#.NET 1.0, Win2K, WinXP, Win2003, Dev
Posted:16 Mar 2004
Views:63,858
Bookmarked:29 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
15 votes for this article.
Popularity: 4.33 Rating: 3.68 out of 5
2 votes, 13.3%
1

2
3 votes, 20.0%
3
6 votes, 40.0%
4
4 votes, 26.7%
5

Sample Image - 009.jpg

Introduction

First of all, I am a newbie at C#. I started it from only two days ago so, sorry for the experts if they didn�t like my article or didn�t find anything useful here. But I think there is some one who may need it to improve his application's interface. The trick is same as the technique which is used at the movies to make the actors do the scene at a room the walls of which is painted with a illuminated color, then the graphic designers put another scene of a forest or a planet or any place else, this is how it works for us.

The first step is to make the required Form graphics by any graphics tool (I usually use the Photoshop). The form graphics must have the background color as illuminated green because this color can be easily grouped and deleted without deleting any edges of the shape you want. In other words, if we used non illuminated color, the dark edges of the shape will be deleted with the background color.

Any way the work will show how it is done, as I did in my sample. You can see what I was saying:

Sample screenshot

But the main problem is that Visual studio needs the same exact color as the background and if you mismatched this rule, the background color will stick to your form. If we take a closer view of our painted form, you can see a small difference at a point on the curved edges:

Sample screenshot

The Visual Studio considers it as a different color than the background, so it leaves it without deleting and it looks very awful at your form as:

Sample screenshot

So try to eliminate all different colors from your graphic before using it. Now another thing �. When you save your background color, try to make the background color take a little space from it because the VS considers it as a part of the form although it eliminates it.

Now save your work as .bmp file and open VS.NET. Make a project that contains a C# empty form and start modifying it as the following:

Sample screenshot

Add the button and the label you want and adjust the form properties as the following:

  • BackgroundImage: your background with extension .bmp
  • FormBorderStyle: None
  • TransparencyKey: Web, then choose Lime

Adjust the Button properties as the following:

  • BackColor: Web, then choose White Smoke
  • Text: OK

Adjust the Label properties as the following:

  • BackColor: Web, then choose Transparent
  • FlatStyle: Popup

Add this code to the button1_Click function:

Application.Exit();

If you want your form moveable, you can use the code at Jibin's article (Interactive Shaped Forms). That is all.

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

About the Author

Hossam Abbas


Member
PMI member with more than 7 years of IT and Automation experience in the Aviation and oil & gas sectors. Managed and participated in several projects playing several roles. Experience with latest IT and Automation tools and technologies such as Oracle, J2EE, .Net, PI OSI Real Time DB Systems, with a solid experience in Oil and Gas down stream automation industry, software design and analysis methodologies such as: SDLC, Iterative method, ERD, DFD, FHD, OOAD, SOA,UML and Design patterns.
Occupation: Other
Company: Trust Technical Services
Location: Egypt Egypt

Other popular .NET Framework articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 21 of 21 (Total in Forum: 21) (Refresh)FirstPrevNext
GeneralThis way it'll work Pinmemberbalazs_hideghety2:40 18 Aug '09  
Generalchange color depth and it will work Pinmemberosamahamed1232:30 26 Feb '06  
GeneralThe true way to make any shaped form PinmemberRezaul22:08 17 Oct '04  
GeneralThanks and another trick PinsussRAAK11:44 3 Apr '04  
GeneralRe: Thanks and another trick PinmemberH_LionHeart13:58 28 Apr '04  
Generaldidn't worked Pinmembervandana chadha19:51 28 Mar '04  
GeneralVery clean...Thanks Pinmemberservero1:08 26 Mar '04  
GeneralNot on NT4 PinmemberMartin Robins6:47 23 Mar '04  
GeneralRe: Not on NT4 PinmemberH_LionHeart13:44 23 Mar '04  
GeneralRe: Not on NT4 PinmemberEd.Poore5:56 12 Mar '06  
Generaldoesnt work for me Pinmember_taz_2:41 18 Mar '04  
GeneralRe: doesnt work for me PinmemberLoneRanger4:55 18 Mar '04  
GeneralRe: doesnt work for me PinmemberH_LionHeart4:57 18 Mar '04  
GeneralRe: doesnt work for me PinmemberMatthew Hazlett9:21 18 Mar '04  
GeneralRe: doesnt work for me PinmemberH_LionHeart10:40 18 Mar '04  
GeneralRe: doesnt work for me Pinmemberkareemshaker23:01 20 Mar '04  
GeneralWorks for me! Pinmemberbreinholt12:23 25 Mar '04  
GeneralRe: doesnt work for me PinmemberH_LionHeart13:56 28 Apr '04  
GeneralRe: doesnt work for me Pinmemberdjones793618:46 27 Mar '04  
GeneralRe: doesnt work for me Pinmembergazza_11:36 28 Mar '04  
GeneralRe: doesnt work for me PinmemberH_LionHeart14:18 28 Mar '04  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 16 Mar 2004
Editor: Smitha Vijayan
Copyright 2004 by Hossam Abbas
Everything else Copyright © CodeProject, 1999-2009
Web18 | Advertise on the Code Project