Windows Develop Bookmark and Share   
 index > Windows Forms General > Logging into MDI Application
 

Logging into MDI Application

First off, I'm just starting to learn to program in VB.NET.  I am trying to create a login for a MDI application!  My problem is once i get a user authenticated I want to open up the main MDI window and then close the login form.  Here is my code snipet:

            If blnAuthenticated = True Then
                frm = New frmMain()
                frm.Show()
                Me.Close()
            Else
                MessageBox.Show("Invalid Login!" & Chr(13) & Chr(10) & _
                    "Please Check username and password", "Invalid Login", _
                    MessageBoxButtons.OK, MessageBoxIcon.Hand)
                txtUsername.Focus()
            End If

blnAuthenticated is set to true or false based upon a login function in seperate class file.  Im gettin the expected Result from the function. But when it comes back true, the app closes (I'm thinking because of the me.close).  If I change me.close to me.hide the app works how i want it to until i go to close the MDI window!  The app continues to run because the the login form is only hidden.  Does anyone have a good Login example or give me a few pointers!

Thanks
MigrationUser 1  Monday, December 01, 2003 4:29 PM
I have worked around my problem by creating a Sub Main to start my application.  Although if anyone out there has some better advice than my hack around, it would be greatly appreciated.  I would still rather use my Login form as the startup object rather than sub main!

Thanks
MigrationUser 1  Tuesday, December 02, 2003 3:53 PM
If you want to use the Login form, all you need to do is call Hide after you are done with all the authentication goodies.

                Me.Hide()
                Dim f As New MainForm
                f.Show()

In the MDIParent, which in this case is MainForm, you can then show a splash screen, or simply wait for everything on the MDIParent to load.

Remember, if you are starting from a Login form, and you close it, the application will end.  To see an example of all of this in action, you can download a reference app i wrote for Infragistics at http://devcenter.infragistics.com/RefApps/Tracker/tracker.aspx.  You'll also get good examples of threading, and communicating between child and parent forms in a MDI application.
MigrationUser 1  Saturday, December 06, 2003 6:40 PM
Jason~

Thanks for the help!!! Sorry for the long overdue THANKS,  but had to put the application on the back burner for a few months because of a couple other priorities.  I have had a few people tell me that I shouldn't "hide" forms for whatever reason.  But the "Application.Exit" seems to take care of it!

Thanks again,
Derek
MigrationUser 1  Tuesday, April 06, 2004 4:31 PM

You can use google to search for other answers

Custom Search

More Threads

• Access to .NET converter
• Quicktime COM control giving "AccessViolationException"
• MenuItems
• 'The folder path contains an invalid character' error when tryin to install an service
• How to increase resolution of the bitmap?
• event +C#
• Grouping in datagrid
• How to display a MessageBox as topmost window
• securing a folder
• delete multipl items from list box-key driven