471,338 Members | 1,019 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,338 software developers and data experts.

Hide Login screen when entering application

I am new to .Net and Visual Studio, I have a login form and my main
application form. When I login I want to call the application form, and
dispose of the login. I have tried doing something like:

This.Hide
myAppfrm.Show();

but then when I close down the myAppfrm, the system hangs as the login
screen is still floating about in memory. How is this delt with normally in
the .Net fraternity?

Thanks
Jul 21 '05 #1
3 2272
I have done this now, which seems to do the job but not sure how right it is:

if(loggedIn == true)
{
MainScreen myMainScreen = new MainScreen();
this.Hide();
myMainScreen.ShowDialog();
this.dispose();
}

so now it runs the application, then disposes the hidden login screen when
they close the application. Is this correct?
"Steve" wrote:
I am new to .Net and Visual Studio, I have a login form and my main
application form. When I login I want to call the application form, and
dispose of the login. I have tried doing something like:

This.Hide
myAppfrm.Show();

but then when I close down the myAppfrm, the system hangs as the login
screen is still floating about in memory. How is this delt with normally in
the .Net fraternity?

Thanks

Jul 21 '05 #2
You will need to create a Sub Main() Method within a module and set
the Main() method as the startup object, this can be done in the
project properties dialog

the module containing the Sub Main() method will then need to contain
something similar to the following

Module modMain

Public Sub Main()

Dim objLoginForm as New LoginForm

'Use showdialog() instead of show() to stop the
'application from displaying the main form until the
login form has been closed
objLoginForm.ShowDialog

'Create the main form
Dim myAppfrm as new YourMainForm

'Use Application.Run instead of myAppfrm.show as this
will then treat the myAppfrm as the main message loop and not exit the
application until it has closed
Application.Run(myAppfrm)

End Sub

End Module

I hope this helps.

Regards

James Thresher
On Wed, 15 Jun 2005 03:14:03 -0700, "Steve"
<St***@discussions.microsoft.com> wrote:
I am new to .Net and Visual Studio, I have a login form and my main
application form. When I login I want to call the application form, and
dispose of the login. I have tried doing something like:

This.Hide
myAppfrm.Show();

but then when I close down the myAppfrm, the system hangs as the login
screen is still floating about in memory. How is this delt with normally in
the .Net fraternity?

Thanks


Jul 21 '05 #3
Hi,

Just noticed that you are using c#, my previous post was a solution
for VB.NET, my apologies. the following should work for c#
[STAThread]
static void Main()
{

LoginForm objLoginForm = new LoginForm();

//Use showdialog() instead of show() to stop the
//application from displaying the main form until the
login form has been closed
objLoginForm.ShowDialog();

//Create the main form
YourMainForm myAppfrm = new YourMainForm();

//Use Application.Run instead of myAppfrm.show as this
will then treat the myAppfrm as the main message loop and not exit the
application until it has closed
Application.Run(myAppfrm());

}

Regards

James Thresher

On Wed, 15 Jun 2005 03:14:03 -0700, "Steve"
<St***@discussions.microsoft.com> wrote:
I am new to .Net and Visual Studio, I have a login form and my main
application form. When I login I want to call the application form, and
dispose of the login. I have tried doing something like:

This.Hide
myAppfrm.Show();

but then when I close down the myAppfrm, the system hangs as the login
screen is still floating about in memory. How is this delt with normally in
the .Net fraternity?

Thanks


Jul 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Just D. | last post: by
4 posts views Thread by BrianDH | last post: by
1 post views Thread by beachboy | last post: by
10 posts views Thread by =?Utf-8?B?UmljaGFyZCBCeXNvdXRo?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.