Beauty is only Skin-Deep Part Deux: If it looks like a duck, it might be a WinForm

Published 19 May 08 07:57 AM | jacobl 

If it looks like a duck, quacks like a duck, and waddles like a duck, then it's probably a duck. But if it just looks like one, it might be my next WinForms application. Ah, and yes it is. This blog will put a useless spin on creating non-standard shaped WinForm applications. There are real uses for this practice like adding rounded corners or creating great looking splash screens, but outside of showing you how to do it, I'm not sure if the sample app I'm going to create will sell very well...

Let's Get Started

Open your favorite photo in a photo editor and crop it out so that it takes on the shape of your favorite feathered friend. Making sure the background is transparent, save it as a PNG and add it as a resource to a new WinForms project in Visual Studio.

Feather Your Form

Just like I discussed in my last blog,  Beauty is only Skin-Deep: Skinning your WinForms Application, we need to set the FormBorderStyle to None. This will get rid of the top bar and close, minimize, and maximize buttons. After that's done, let's add a PictureBox that contains our manic mallard to the form. You will need to resize your form to fit it all in.


Transparency Is Key

The last step to proving that I'm truly quacked is to set the TransparencyKey of the Form. To do this scroll to the bottom of the properties pane and changing the selected drop down item to match that of the BackColor property. The trick here is to make sure that you want that color to always be transparent in your application. In the case of my duck, I'm pretty sure the web color, Thistle, will be a safe bet. So, I'm choosing that as the BackColor for my form as well as the TransparencyKey.

That's it! Run your app and you will see it in all its glory!


Finishing Touches

Check out my last blog to add a close button and dragability to this cute canard and you've got yourself one of the most useless apps ever made. But that isn't why we did this, is it? The ability to apply TransparencyKeys to your applications will allow you to create skinned interfaces that have rounded corners and very attractive splash screens to set your application ahead of the pack.

Be warned, though; a little goes a long way! Skinning your application has to enhance usability or it is simply a step backwards. One of the most taken-for-granted usability enhancement is familiarity. So, if you intend on altering your WinForms, be sure to ease up and keep things simple.

The Code

There is no "code", per se, but I am attaching my project with it's modified properties and my beautifully cropped duck as a resource. Enjoy!

Get the Source Here 

Filed under: , ,


# said on May 19, 2008 8:20 AM:

You've been kicked (a good thing) - Trackback from

Anonymous comments are disabled