Decorate your .Net WinForm application in a peculiar way

This article actually was written in last Christmas, now I just re-post in my new home.

Every programmer wants his application GUI to stand out, and so do I. A new idea came into my mind. I would like to add a Christmas hat on the top left corner of my WinForm application. This is not only simple but also not adding too much work load.

.Net application skin could be the first solution for most programmer. But it seems not worth it, because a huge skin library has to be installed just for this simple function. Furthermore, commercial skin library is not free at all.

I have to go back google again. Someone mention that it can override WndProc and in WM_NCPAINT, you have to draw your own title bar, and write function for each button. It seems a lot of work to do.Finally, I invent this peculiar way.

1. Create a transparent Form,
2. Put only a hat inside
3. Let it stay on the top left corner

private void Form1_LocationChanged(object sender, System.EventArgs e)
{
    hat.Location = new Point(this.Location.X-30,this.Location.Y-10);
}

private void Form1_Activated(object sender, System.EventArgs e)
{
    if(!hat.TopMost)
    {
        hat.TopMost = true;
        hat.BringToFront();
    }
}

private void Form1_Deactivate(object sender, System.EventArgs e)
{
    if(hat.TopMost)
        hat.TopMost = false;
}

2 thoughts on “Decorate your .Net WinForm application in a peculiar way”

  1. Greetings, I just thought I would personally post and inform you that the blogs page layout is actually messed up on the Firefox browser. Appear to work alright in Internet Explorer although. Anyways maintain up the fine work.

Comments are closed.