Click here to Skip to main content
15,896,726 members
Home / Discussions / C#
   

C#

 
AnswerRe: Setting a variable value from an array. Pin
Giorgi Dalakishvili5-Jun-07 5:56
mentorGiorgi Dalakishvili5-Jun-07 5:56 
GeneralRe: Setting a variable value from an array. Pin
jblouir5-Jun-07 6:21
jblouir5-Jun-07 6:21 
AnswerRe: Setting a variable value from an array. Pin
Hesham Yassin6-Jun-07 8:06
Hesham Yassin6-Jun-07 8:06 
QuestionApplication is closing when i hide it...! Pin
Affan Toor5-Jun-07 5:37
Affan Toor5-Jun-07 5:37 
AnswerRe: Application is closing when i hide it...! Pin
blakey4045-Jun-07 5:50
blakey4045-Jun-07 5:50 
AnswerRe: Application is closing when i hide it...! Pin
Luc Pattyn5-Jun-07 6:06
sitebuilderLuc Pattyn5-Jun-07 6:06 
GeneralRe: Application is closing when i hide it...! Pin
Affan Toor5-Jun-07 6:23
Affan Toor5-Jun-07 6:23 
GeneralRe: Application is closing when i hide it...! Pin
Ian Shlasko5-Jun-07 7:06
Ian Shlasko5-Jun-07 7:06 
ShowDialog is the problem. It stops blocking when the form is closed OR hidden. Basically, it's the wrong method to use in this situation.

There are plenty of ways to set this up, but here's one suggestion:

<br />
static void Main()<br />
{<br />
 ...styles and such...<br />
 frmSplash splash = new frmSplash();<br />
 Application.Run(splash);<br />
 frmMain main = splash.GetMainForm();<br />
 Application.Run(main);<br />
}<br />


In frmSplash:

<br />
private frmMain _mainForm;<br />
public frmMain GetMainForm() { return _mainForm; }<br />


In frmSplash_Load (Or wherever you want to do the actual work):

<br />
_mainForm = new frmMain();<br />
...<br />
this.Hide();<br />


Basically, the sequence of events here is:

1) Main() runs an application loop on the splash form
2) Splash form, once loaded, loads the main form
3) Splash form hides itself
4) Main() continues, and grabs a reference to the main form
5) Main() closes down the Splash form (It was just hidden)
6) Main() runs an application loop on the main form

I'm sure there are many other, and better, ways to do this, but here's the first example I came up with.

ADDENDUM to clarify: The point of this, is that if your frmMain instance is called from an Application.Run() instead of a ShowDialog, the application won't exit until it actually closes, so you can hide it all you want.
GeneralRe: Application is closing when i hide it...! Pin
Luc Pattyn5-Jun-07 7:44
sitebuilderLuc Pattyn5-Jun-07 7:44 
GeneralRe: Application is closing when i hide it...! Pin
Affan Toor6-Jun-07 2:03
Affan Toor6-Jun-07 2:03 
QuestionReagrding Xml serialization Pin
ksrs5-Jun-07 5:10
ksrs5-Jun-07 5:10 
AnswerRe: Reagrding Xml serialization Pin
Giorgi Dalakishvili5-Jun-07 5:40
mentorGiorgi Dalakishvili5-Jun-07 5:40 
QuestionRe: Reagrding Xml serialization Pin
ksrs5-Jun-07 6:45
ksrs5-Jun-07 6:45 
Questionvc++ to c# .NET Pin
Kabirdas Jaunjare5-Jun-07 5:05
Kabirdas Jaunjare5-Jun-07 5:05 
AnswerRe: vc++ to c# .NET Pin
originSH5-Jun-07 5:35
originSH5-Jun-07 5:35 
QuestionNewbie trying very hard not to pull my hair out!!! Pin
allan.gagnon5-Jun-07 4:59
allan.gagnon5-Jun-07 4:59 
AnswerRe: Newbie trying very hard not to pull my hair out!!! Pin
kubben5-Jun-07 5:36
kubben5-Jun-07 5:36 
Questionhow to sort an unbound column in datagridview Pin
ChupaChupa5-Jun-07 4:57
ChupaChupa5-Jun-07 4:57 
QuestionCheck type of object Pin
SVb.net5-Jun-07 4:18
SVb.net5-Jun-07 4:18 
AnswerRe: Check type of object Pin
Not Active5-Jun-07 4:25
mentorNot Active5-Jun-07 4:25 
AnswerRe: Check type of object Pin
Seishin#5-Jun-07 4:31
Seishin#5-Jun-07 4:31 
QuestionHow to create a custom ScrollBar with VisualStyles Pin
Juan Pablo G.C.5-Jun-07 3:44
Juan Pablo G.C.5-Jun-07 3:44 
QuestionAdding items to ListView Pin
Rajesh R Subramanian5-Jun-07 2:54
professionalRajesh R Subramanian5-Jun-07 2:54 
AnswerRe: Adding items to ListView Pin
teejayem5-Jun-07 3:05
teejayem5-Jun-07 3:05 
GeneralRe: Adding items to ListView Pin
Rajesh R Subramanian5-Jun-07 3:09
professionalRajesh R Subramanian5-Jun-07 3:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.