11 Replies - 1202 Views - Last Post: 05 March 2009 - 08:07 AM Rate Topic: -----

#1 X@MPP  Icon User is offline

  • 僕わ馬鹿ですね?
  • member icon

Reputation: 36
  • View blog
  • Posts: 1,014
  • Joined: 20-February 09

Problem with homemade splash screen

Posted 04 March 2009 - 08:32 AM

I feel stupid for not pasting code but im at school and I don’t have access to my home computer. :blink:
Okay I want to close a form with a timer kind of like a splash screen but sense only onset ha have a built in splash screen is the VB.NET ant the wpf forms im using a normal win form app I have 300+ lines of code so far and I have tried with all kinds of timer configs and code it ether kicks of my try catch stament and I get a critical error or it fires ok good but doesn’t do anything. any help thanks in advanced

Is This A Good Question/Topic? 0
  • +

Replies To: Problem with homemade splash screen

#2 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6078
  • View blog
  • Posts: 23,549
  • Joined: 23-August 08

Re: Problem with homemade splash screen

Posted 04 March 2009 - 08:38 AM

Holy run-on sentence, Batman!

You need to provide code and the errors being thrown for us to be helpful.
Was This Post Helpful? 0
  • +
  • -

#3 X@MPP  Icon User is offline

  • 僕わ馬鹿ですね?
  • member icon

Reputation: 36
  • View blog
  • Posts: 1,014
  • Joined: 20-February 09

Re: Problem with homemade splash screen

Posted 04 March 2009 - 08:44 AM

View PostJackOfAllTrades, on 4 Mar, 2009 - 07:38 AM, said:

Holy run-on sentence, Batman!

You need to provide code and the errors being thrown for us to be helpful.

im at school i cant

i was just reading http://www.dreaminco...wtopic89868.htm and i will try that. if not i will try something else :crazy:
Was This Post Helpful? 0
  • +
  • -

#4 X@MPP  Icon User is offline

  • 僕わ馬鹿ですね?
  • member icon

Reputation: 36
  • View blog
  • Posts: 1,014
  • Joined: 20-February 09

Re: Problem with homemade splash screen

Posted 04 March 2009 - 06:43 PM

i still havent got it
hears my code that i have so far and the code for the splash screen is just the defalt and a button click that closes the form
okay be prepared now this is 300+ lines
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;



namespace LogonTest2
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		
		private void Form1_Load(object sender, EventArgs e)
		{
			try
			{
				if (Properties.Settings.Default.Splash_Screen == "On")
				{
					
					SplashScreen splash = new SplashScreen();
					splash.Show();
					
					
				}
				button4.Hide();
				button5.Hide();
				richTextBox1.ReadOnly = true;
				richTextBox1.Text = "Pasive";
				//Clears the image befor showing next one
				if (pictureBox1.Image != null)
				{
					pictureBox1.Image.Dispose();
					pictureBox1.Image = null;
				}
				//at start hides stop button
				button2.Hide();
				label3.Text = "Pasive";

				//Reset the text boxes
				textBox2.Text = "";//Resets the user name
				textBox3.Text = "";//resets the password
				label6.Hide();
				pictureBox1.Image = Properties.Resources.stop;
				progressBar1.Hide();
				button3.Hide();

			}
			catch 
			{
				Critical_Error z = new Critical_Error();
				z.Show();
				
			}
		}
	   

		private void button1_Click(object sender, EventArgs e)
		{
			//textBox2 is User Name box
			if (textBox2.Text == Properties.Settings.Default.Username)
			{	  //textBox3 is Password box
				if (textBox3.Text == Properties.Settings.Default.Password)
				{
					
						button4.Show();
						richTextBox1.Text = "";
						richTextBox1.ReadOnly = false;
						//Clears the image befor showing next one
						if (pictureBox1.Image != null)
						{
							pictureBox1.Image.Dispose();
							pictureBox1.Image = null;
						}
						//Reset the text boxes
						textBox2.Text = "";//Resets the user name
						textBox3.Text = "";//resets the password
						button1.Hide();//Hides start button
						button2.Show();//Shows stop button
						//sets label3 text to Curent Stats
						label3.Text = "Active";

						//Sets the stat image to start.png
						pictureBox1.Image = Properties.Resources.start;
						label6.Show();
						label5.Hide();
						progressBar1.Show();
						button3.Show();
						button5.Show();
					
					
					
				}
				else
				{
					//Clears the image befor showing next one
					if (pictureBox1.Image != null)
					{
						pictureBox1.Image.Dispose();
						pictureBox1.Image = null;
					}
					pictureBox1.Image = Properties.Resources.error1;
					//IF No freald are corect
					MessageBox.Show("Error incorrect password can not start");
					//Reset the text boxes
					textBox2.Text = "";//Resets the user name
					textBox3.Text = "";//resets the password
					
				}
			}
			else 
			{
				//Clears the image befor showing next one
				if (pictureBox1.Image != null)
				{
					pictureBox1.Image.Dispose();
					pictureBox1.Image = null;
				}
				pictureBox1.Image = Properties.Resources.error1;
				//IF No freald are corect
				MessageBox.Show("Error incorrect user name can not start");
				//Reset the text boxes
				textBox2.Text = "";//Resets the user name
				textBox3.Text = "";//resets the password
				
				
			}
		}

		

		private void button2_Click(object sender, EventArgs e)
		{	  //textBox2 is User Name box
			if (textBox2.Text == Properties.Settings.Default.Username)
			{	  //textBox3 is Password box
				if (textBox3.Text == Properties.Settings.Default.Password)
				{
					if (textBox2.Text != null && textBox3.Text != null && textBox2.Text != "" && textBox3.Text != "")
					{

						button4.Hide();
						richTextBox1.Text = "Pasive";
						richTextBox1.ReadOnly = true;
						//Clears image befor showing next one
						if (pictureBox1.Image != null)
						{
							pictureBox1.Image.Dispose();
							pictureBox1.Image = null;
						}
						//Reset the text boxes
						textBox2.Text = "";//Resets the user name
						textBox3.Text = "";//resets the password
						button1.Show();//Shows Start Button
						button2.Hide();//Hides Stop Button
						//sets label3 text to Curent Stats
						label3.Text = "Pasive";

						//sets stat image to stop.png
						pictureBox1.Image = Properties.Resources.stop;
						label6.Hide();
						label5.Show();
						progressBar1.Hide();
						button3.Hide();
						button5.Hide();
					}
					else
					{
						//Clears the image befor showing next one
					if (pictureBox1.Image != null)
					{
						pictureBox1.Image.Dispose();
						pictureBox1.Image = null;
					}
					pictureBox1.Image = Properties.Resources.error1;
					//IF No freald are corect
					MessageBox.Show("Error enter a valed user name And Password");
					}
				}
				else
				{
					//Clears the image befor showing next one
					if (pictureBox1.Image != null)
					{
						pictureBox1.Image.Dispose();
						pictureBox1.Image = null;
					}
					pictureBox1.Image = Properties.Resources.error1;
					//IF No freald are corect
					MessageBox.Show("Error incorrect password can not stop");
					//Reset the text boxes
					textBox2.Text = "";//Resets the user name
					textBox3.Text = "";//resets the password
					
				}
			}
			else
			{
				//Clears the image befor showing next one
				if (pictureBox1.Image != null)
				{
					pictureBox1.Image.Dispose();
					pictureBox1.Image = null;
				}
				pictureBox1.Image = Properties.Resources.error1;
				//IF No freald are corect
				MessageBox.Show("Error incorrect user name can not stop");
				//Reset the text boxes
				textBox2.Text = "";//Resets the user name
				textBox3.Text = "";//resets the password
				
			}
			
		}

		private void button3_Click(object sender, EventArgs e)
		{
			progressBar1.Minimum = 0;
			progressBar1.Maximum = 100;
			progressBar1.Step = 1;
			// Create a SaveFileDialog to request a path and file name to save to.
			SaveFileDialog saveFile1 = new SaveFileDialog();

			//To DO
			
			saveFile1.DefaultExt = "*.rtf";
			saveFile1.Filter = "RTF Files|*.rtf";

			// Determine whether the user selected a file name from the saveFileDialog.
			if (saveFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
			   saveFile1.FileName.Length > 0)
			{
				// Save the contents of the RichTextBox into the file.
				richTextBox1.SaveFile(saveFile1.FileName);
			}


			for (int i = 0; i < 100;i++ )
			{
				
				int percent = (int)(((double)progressBar1.Value / (double)progressBar1.Maximum) * 100);
				label7.Text = percent.ToString() + "%";
				progressBar1.PerformStep();
				
				
				
			}
			
			
			
		}

		private void button4_Click(object sender, EventArgs e)
		{
			// Create an OpenFileDialog to request a file to open.
			OpenFileDialog openFile1 = new OpenFileDialog();

			// Initialize the OpenFileDialog to look for RTF files.
			openFile1.Title = "VSSC files";
			openFile1.DefaultExt = "*.STXTC";
			openFile1.Filter = "Super TXT files (*.STXTC)|*.STXTC|Safe Console Files (*.SCONS)|*.SCONS|Console Files (*.CONS)|*.CONS";

			// Determine whether the user selected a file from the OpenFileDialog.
			if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
			   openFile1.FileName.Length > 0)
			{
				// Load the contents of the file into the RichTextBox.
				richTextBox1.LoadFile(openFile1.FileName, RichTextBoxStreamType.PlainText);
			}
		}

		private void button5_Click(object sender, EventArgs e)
		{
			User_Settings a = new User_Settings();
			a.Show();
		}

		private void testToolStripMenuItem_Click(object sender, EventArgs e)
		{
			AboutBox1 abu = new AboutBox1();
			abu.Show();
		}

		
		

		

	   
	}
}

now hears my splash screen code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace LogonTest2
{
	public partial class SplashScreen : Form
	{
		public SplashScreen()
		{
			InitializeComponent();
		}
	  



		private void button1_Click(object sender, EventArgs e)
		{
			Close();
		}

		


	}
}

This post has been edited by X@MPP: 04 March 2009 - 06:49 PM

Was This Post Helpful? 0
  • +
  • -

#5 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Problem with homemade splash screen

Posted 04 March 2009 - 07:02 PM

So what is the error that appears in your code?
Was This Post Helpful? 0
  • +
  • -

#6 X@MPP  Icon User is offline

  • 僕わ馬鹿ですね?
  • member icon

Reputation: 36
  • View blog
  • Posts: 1,014
  • Joined: 20-February 09

Re: Problem with homemade splash screen

Posted 04 March 2009 - 07:10 PM

View PostCore, on 4 Mar, 2009 - 06:02 PM, said:

So what is the error that appears in your code?


no error i cant get the Splash screen to close
i use the timer ant the timer_tick to try to close the form in 3 seconds
but win i run it nothing hapens the form dosnt close unless i hit the button!

and i cant fix this how i ask how and dont say msdn thay did not help at all!

sorry for the rant=P
Was This Post Helpful? 0
  • +
  • -

#7 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Problem with homemade splash screen

Posted 04 March 2009 - 07:15 PM

I don't see any Timer_Tick event handler in your code. Please, post the code for the timer so we can try to find the source of the problem.
Was This Post Helpful? 0
  • +
  • -

#8 X@MPP  Icon User is offline

  • 僕わ馬鹿ですね?
  • member icon

Reputation: 36
  • View blog
  • Posts: 1,014
  • Joined: 20-February 09

Re: Problem with homemade splash screen

Posted 04 March 2009 - 07:24 PM

ok now i just swiched out the defalt timer for the System.Timers.timer
ok
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Threading;



namespace LogonTest2
{
	public partial class Form1 : Form
	{
		public Form1()
		{
			InitializeComponent();
		}

		
		private void Form1_Load(object sender, EventArgs e)
		{
			try
			{
				if (Properties.Settings.Default.Splash_Screen == "On")
				{
					timer1.Enabled = true;
					timer1.Interval = 3000;
					
					SplashScreen splash = new SplashScreen();
					splash.Show();
					
					
				}
				button4.Hide();
				button5.Hide();
				richTextBox1.ReadOnly = true;
				richTextBox1.Text = "Pasive";
				//Clears the image befor showing next one
				if (pictureBox1.Image != null)
				{
					pictureBox1.Image.Dispose();
					pictureBox1.Image = null;
				}
				//at start hides stop button
				button2.Hide();
				label3.Text = "Pasive";

				//Reset the text boxes
				textBox2.Text = "";//Resets the user name
				textBox3.Text = "";//resets the password
				label6.Hide();
				pictureBox1.Image = Properties.Resources.stop;
				progressBar1.Hide();
				button3.Hide();

			}
			catch 
			{
				Critical_Error z = new Critical_Error();
				z.Show();
				
			}
		}
	   

		private void button1_Click(object sender, EventArgs e)
		{
			//textBox2 is User Name box
			if (textBox2.Text == Properties.Settings.Default.Username)
			{	  //textBox3 is Password box
				if (textBox3.Text == Properties.Settings.Default.Password)
				{
					
						button4.Show();
						richTextBox1.Text = "";
						richTextBox1.ReadOnly = false;
						//Clears the image befor showing next one
						if (pictureBox1.Image != null)
						{
							pictureBox1.Image.Dispose();
							pictureBox1.Image = null;
						}
						//Reset the text boxes
						textBox2.Text = "";//Resets the user name
						textBox3.Text = "";//resets the password
						button1.Hide();//Hides start button
						button2.Show();//Shows stop button
						//sets label3 text to Curent Stats
						label3.Text = "Active";

						//Sets the stat image to start.png
						pictureBox1.Image = Properties.Resources.start;
						label6.Show();
						label5.Hide();
						progressBar1.Show();
						button3.Show();
						button5.Show();
					
					
					
				}
				else
				{
					//Clears the image befor showing next one
					if (pictureBox1.Image != null)
					{
						pictureBox1.Image.Dispose();
						pictureBox1.Image = null;
					}
					pictureBox1.Image = Properties.Resources.error1;
					//IF No freald are corect
					MessageBox.Show("Error incorrect password can not start");
					//Reset the text boxes
					textBox2.Text = "";//Resets the user name
					textBox3.Text = "";//resets the password
					
				}
			}
			else 
			{
				//Clears the image befor showing next one
				if (pictureBox1.Image != null)
				{
					pictureBox1.Image.Dispose();
					pictureBox1.Image = null;
				}
				pictureBox1.Image = Properties.Resources.error1;
				//IF No freald are corect
				MessageBox.Show("Error incorrect user name can not start");
				//Reset the text boxes
				textBox2.Text = "";//Resets the user name
				textBox3.Text = "";//resets the password
				
				
			}
		}

		

		private void button2_Click(object sender, EventArgs e)
		{	  //textBox2 is User Name box
			if (textBox2.Text == Properties.Settings.Default.Username)
			{	  //textBox3 is Password box
				if (textBox3.Text == Properties.Settings.Default.Password)
				{
					if (textBox2.Text != null && textBox3.Text != null && textBox2.Text != "" && textBox3.Text != "")
					{

						button4.Hide();
						richTextBox1.Text = "Pasive";
						richTextBox1.ReadOnly = true;
						//Clears image befor showing next one
						if (pictureBox1.Image != null)
						{
							pictureBox1.Image.Dispose();
							pictureBox1.Image = null;
						}
						//Reset the text boxes
						textBox2.Text = "";//Resets the user name
						textBox3.Text = "";//resets the password
						button1.Show();//Shows Start Button
						button2.Hide();//Hides Stop Button
						//sets label3 text to Curent Stats
						label3.Text = "Pasive";

						//sets stat image to stop.png
						pictureBox1.Image = Properties.Resources.stop;
						label6.Hide();
						label5.Show();
						progressBar1.Hide();
						button3.Hide();
						button5.Hide();
					}
					else
					{
						//Clears the image befor showing next one
					if (pictureBox1.Image != null)
					{
						pictureBox1.Image.Dispose();
						pictureBox1.Image = null;
					}
					pictureBox1.Image = Properties.Resources.error1;
					//IF No freald are corect
					MessageBox.Show("Error enter a valed user name And Password");
					}
				}
				else
				{
					//Clears the image befor showing next one
					if (pictureBox1.Image != null)
					{
						pictureBox1.Image.Dispose();
						pictureBox1.Image = null;
					}
					pictureBox1.Image = Properties.Resources.error1;
					//IF No freald are corect
					MessageBox.Show("Error incorrect password can not stop");
					//Reset the text boxes
					textBox2.Text = "";//Resets the user name
					textBox3.Text = "";//resets the password
					
				}
			}
			else
			{
				//Clears the image befor showing next one
				if (pictureBox1.Image != null)
				{
					pictureBox1.Image.Dispose();
					pictureBox1.Image = null;
				}
				pictureBox1.Image = Properties.Resources.error1;
				//IF No freald are corect
				MessageBox.Show("Error incorrect user name can not stop");
				//Reset the text boxes
				textBox2.Text = "";//Resets the user name
				textBox3.Text = "";//resets the password
				
			}
			
		}

		private void button3_Click(object sender, EventArgs e)
		{
			progressBar1.Minimum = 0;
			progressBar1.Maximum = 100;
			progressBar1.Step = 1;
			// Create a SaveFileDialog to request a path and file name to save to.
			SaveFileDialog saveFile1 = new SaveFileDialog();

			//To DO
			
			saveFile1.DefaultExt = "*.rtf";
			saveFile1.Filter = "RTF Files|*.rtf";

			// Determine whether the user selected a file name from the saveFileDialog.
			if (saveFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
			   saveFile1.FileName.Length > 0)
			{
				// Save the contents of the RichTextBox into the file.
				richTextBox1.SaveFile(saveFile1.FileName);
			}


			for (int i = 0; i < 100;i++ )
			{
				
				int percent = (int)(((double)progressBar1.Value / (double)progressBar1.Maximum) * 100);
				label7.Text = percent.ToString() + "%";
				progressBar1.PerformStep();
				
				
				
			}
			
			
			
		}

		private void button4_Click(object sender, EventArgs e)
		{
			// Create an OpenFileDialog to request a file to open.
			OpenFileDialog openFile1 = new OpenFileDialog();

			// Initialize the OpenFileDialog to look for RTF files.
			openFile1.Title = "VSSC files";
			openFile1.DefaultExt = "*.STXTC";
			openFile1.Filter = "Super TXT files (*.STXTC)|*.STXTC|Safe Console Files (*.SCONS)|*.SCONS|Console Files (*.CONS)|*.CONS";

			// Determine whether the user selected a file from the OpenFileDialog.
			if (openFile1.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
			   openFile1.FileName.Length > 0)
			{
				// Load the contents of the file into the RichTextBox.
				richTextBox1.LoadFile(openFile1.FileName, RichTextBoxStreamType.PlainText);
			}
		}

		private void button5_Click(object sender, EventArgs e)
		{
			User_Settings a = new User_Settings();
			a.Show();
		}

		private void testToolStripMenuItem_Click(object sender, EventArgs e)
		{
			AboutBox1 abu = new AboutBox1();
			abu.Show();
		}

		private void timer1_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
		{
			SplashScreen splash = new SplashScreen();
			splash.Close();
		}
	   
	}
}


Was This Post Helpful? 0
  • +
  • -

#9 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Problem with homemade splash screen

Posted 04 March 2009 - 07:46 PM

You have to start the application with the SplashScreen. To do this, open your Program.cs file and find the following line:

Application.Run(new Form1());



Change Form1 to the name of the splash screen. Then, on the splash screen form, add a Timer control, set its interval for 3000 and enable it. For the Timer_Tick event, add this code:

this.Close();


Was This Post Helpful? 0
  • +
  • -

#10 X@MPP  Icon User is offline

  • 僕わ馬鹿ですね?
  • member icon

Reputation: 36
  • View blog
  • Posts: 1,014
  • Joined: 20-February 09

Re: Problem with homemade splash screen

Posted 04 March 2009 - 07:54 PM

View PostCore, on 4 Mar, 2009 - 06:46 PM, said:

You have to start the application with the SplashScreen. To do this, open your Program.cs file and find the following line:

Application.Run(new Form1());



Change Form1 to the name of the splash screen. Then, on the splash screen form, add a Timer control, set its interval for 3000 and enable it. For the Timer_Tick event, add this code:

this.Close();


well would that close the app cuz that sets the splash as the main form right??
and wen you close the mail form the app shuts down
UPDATE; just as i set my app shutdown ha

----------------
Now playing: Habib Koité and Bamada - Din Din Wo (Little Child)
via FoxyTunes

----------------
Now playing: O-ZONE - Dragostea Din Tei
via FoxyTunes

This post has been edited by X@MPP: 04 March 2009 - 08:03 PM

Was This Post Helpful? 0
  • +
  • -

#11 Core  Icon User is offline

  • using System.Linq;
  • member icon

Reputation: 774
  • View blog
  • Posts: 5,097
  • Joined: 08-December 08

Re: Problem with homemade splash screen

Posted 04 March 2009 - 08:21 PM

You could use this instead of Close:

this.Hide();



This will actually make the form invisible and will keep it in the memory, but it could be an alternative solution.
Was This Post Helpful? 0
  • +
  • -

#12 X@MPP  Icon User is offline

  • 僕わ馬鹿ですね?
  • member icon

Reputation: 36
  • View blog
  • Posts: 1,014
  • Joined: 20-February 09

Re: Problem with homemade splash screen

Posted 05 March 2009 - 08:07 AM

no i just fixed it thanks anyway :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1