The Artima Developer Community
Sponsored Link

.NET Buzz Forum
Splash Screens and non-rectangular windows

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Eric Gunnerson

Posts: 1006
Nickname: ericgu
Registered: Aug, 2003

Eric Gunnerson is a program manager on the Visual C# team
Splash Screens and non-rectangular windows Posted: Sep 24, 2003 10:33 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Eric Gunnerson.
Original Post: Splash Screens and non-rectangular windows
Feed Title: Eric Gunnerson's C# Compendium
Feed URL: /msdnerror.htm?aspxerrorpath=/ericgu/Rss.aspx
Feed Description: Eric comments on C#, programming and dotnet in general, and the aerodynamic characteristics of the red-nosed flying squirrel of the Lesser Antilles
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Eric Gunnerson
Latest Posts From Eric Gunnerson's C# Compendium

Advertisement

I needed a splash screen for my music player app. I tried a couple of ideas that didn't work very well, but then I hit on the idea of using the image of a CD as the background of the splash screen - and doing a non-rectangular window. I'll start with the splash screen...

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!

Read: Splash Screens and non-rectangular windows

Topic: ASP.NET Without Web Projects Previous Topic   Next Topic Topic: Internationalization/Globalization and ASP.NET Brainstorming at 1:05am

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use