B
BrianP
I'm trying to get a splash screen working. Yes, I've read the article
at
http://www.codeproject.com/netcf/casoast.asp
I modeled mine after that, but simplified it. I don't have a timer.
I'm just trying to load several forms of my application while the
splash screen is displayed, and call an update() method on the splash
screen after each form is loaded to show progress to the user. To
show the progress, I was trying to just move a rectangle across the
splash screen. The splash screen is displaying and then closing
correctly, but the rectangle isn't moving with each update. I've
verified with breakpoints that the splash form's update() is being
called when it's supposed to, and the onPaint method is being called,
so the problem is almost more of a graphics problem. Or maybe it has
to do with threading and Application.DoEvents(). But I'm mostly a
newb, so the problem could be anything ;-)
Also, I'm still working on VS 2003. That's what I started this
project on awhile ago. I'm now coming back to it after a long pause.
I'm working on getting VS2005, but I'd like to finish it up in 2003
and then convert/upgrade it to 2005.
Here are the relevant code snippets
from the main form :
main form contains
private static SplashForm splash;
private void FormMain_Load(object sender, System.EventArgs e)
{
Thread splashThread = new Thread(new ThreadStart(startSplash));
splashThread.Start();
Global.getBoardForm();
splash.update();
Application.DoEvents();
Global.getNewGameForm();
splash.update();
Application.DoEvents();
etc...
this.Enabled = true;
this.Visible = true;
closeSplash();
}
private void startSplash()
{
splash = new SplashForm();
Application.Run(splash);
}
private void closeSplash()
{
if (splash==null)
return;
splash.Invoke(new EventHandler(splash.KillMe));
splash.Dispose();
splash = null;
}
and the SplashForm :
private int count = 0;
// this will be called when each form is done loading, it basically
means to paint another
// 'progress' rectangle
public void update()
{
count++;
this.Refresh();
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics gx = e.Graphics;
SolidBrush brush = new SolidBrush(Color.DarkCyan);
if(count>0)
{
gx.FillRectangle(brush, startX+(count*20), startY, 18, 35);
}
base.OnPaint (e);
}
Thanks!
at
http://www.codeproject.com/netcf/casoast.asp
I modeled mine after that, but simplified it. I don't have a timer.
I'm just trying to load several forms of my application while the
splash screen is displayed, and call an update() method on the splash
screen after each form is loaded to show progress to the user. To
show the progress, I was trying to just move a rectangle across the
splash screen. The splash screen is displaying and then closing
correctly, but the rectangle isn't moving with each update. I've
verified with breakpoints that the splash form's update() is being
called when it's supposed to, and the onPaint method is being called,
so the problem is almost more of a graphics problem. Or maybe it has
to do with threading and Application.DoEvents(). But I'm mostly a
newb, so the problem could be anything ;-)
Also, I'm still working on VS 2003. That's what I started this
project on awhile ago. I'm now coming back to it after a long pause.
I'm working on getting VS2005, but I'd like to finish it up in 2003
and then convert/upgrade it to 2005.
Here are the relevant code snippets
from the main form :
main form contains
private static SplashForm splash;
private void FormMain_Load(object sender, System.EventArgs e)
{
Thread splashThread = new Thread(new ThreadStart(startSplash));
splashThread.Start();
Global.getBoardForm();
splash.update();
Application.DoEvents();
Global.getNewGameForm();
splash.update();
Application.DoEvents();
etc...
this.Enabled = true;
this.Visible = true;
closeSplash();
}
private void startSplash()
{
splash = new SplashForm();
Application.Run(splash);
}
private void closeSplash()
{
if (splash==null)
return;
splash.Invoke(new EventHandler(splash.KillMe));
splash.Dispose();
splash = null;
}
and the SplashForm :
private int count = 0;
// this will be called when each form is done loading, it basically
means to paint another
// 'progress' rectangle
public void update()
{
count++;
this.Refresh();
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics gx = e.Graphics;
SolidBrush brush = new SolidBrush(Color.DarkCyan);
if(count>0)
{
gx.FillRectangle(brush, startX+(count*20), startY, 18, 35);
}
base.OnPaint (e);
}
Thanks!