Vakul's .NET Realm

My journey towards .NET World…

  • Details

    Vakuls MCPD Certification Vakuls MCTS Certification Author's Pic



  • Blog Stats

    • 142,380 hits
  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 355 other followers

  • Follow me in Twitter:




  • qrcode
  • Subscribe

  • del.icio.us:

Splash Screens and non-rectangular windows

Posted by Vakul Kumar More on October 29, 2006


While searching, I found a very interesting article in a blog. It was about to create a splash screen. This article is extracted from that site. Check out for the link of the blog at the end of the article.


Conceptually, a splash screen is pretty simple – it’s just a form that you bring up at the start of the program. The code is something like this:

SplashForm splashForm;
public MyForm()
{
    splashForm = new SplashForm();
    splashForm.Show();
}

and we’ll hook the Activated event to hide the form.

private void Form1_Activated(object sender, System.EventArgs e){
    splashForm.Close();
}

When we run this, however, something strange happens. The form comes up, but it never renders – there’s just a black background. This is because we need the windows messages to be processed to get the form to paint. There are several ways to do this, but my choice is to simply call Application.DoEvents() after the form is shown. This processes any messages that have yet to be processed, showing the form.Next, we need to make a non-rectangular form. This is done by setting the region on the form. This is surprisingly easy to do. Here’s the code I used for the CD:

public SplashForm()
{
    GraphicsPath p = new GraphicsPath();
    p.AddEllipse(2, 4, 340, 341);
    p.AddEllipse(150, 153, 43, 43);
    this.Region = new Region(p);

    …
}

The first ellipse defines the outside of the picture, and then the second one this inside. This gives me a round window with a hole in the center.

Pretty cool!

Article Link: http://blogs.msdn.com/ericgu/archive/2003/09/24/52645.aspx

Advertisements

One Response to “Splash Screens and non-rectangular windows”

  1. Thanks for information.
    many interesting things
    Celpjefscylc

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: