How to get a proper login screen

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Twizz
    New Member
    • May 2010
    • 2

    How to get a proper login screen

    Hey, I recently started with C# and I've done some things in XNA, 2D and 3D etc but now I'm trying to start with window programming.

    Atm I've done a program who start a normal form where you enter your username and password, when you press ENTER your information will be checked and it will close the login menu and open a new form named CSystem.

    I'm trying to get it to work like this

    When I enter the program I'll get a login screen, when I enter my user/pass etc and press ENTER I want it to check the information and instead of close and open a new form I want everything, all labels etc, in the login form to "disappear" and new stuff will be on the screen.

    Like when you play a game hmm, lets say World of Warcraft, when you enter your login information the program won't close and open a new window if you understand what I mean.

    If you know any good tutorials or anything else please leave a comment.

    Sorry for my bad English :(

    //grateful for answer
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    When you show the Main Form after the login screen...
    means. when you do something like this

    Code:
    Form2.Show();
    Close the current form (Login form) by doing this

    Code:
    this.Close();

    Comment

    • Twizz
      New Member
      • May 2010
      • 2

      #3
      I've already tried this but it won't load in the same WINDOW, it still closes the form and start a new one, maybe I'm way out of line and maybe I shouldn't use FORM at all.

      Maybe I need to use DMI containers but I don't think so, just trying to get everything in the same window, like in JAVA you can clear the window and call method to write out the new stuff instead of open a new form.

      Comment

      • GaryTexmo
        Recognized Expert Top Contributor
        • Jul 2009
        • 1501

        #4
        Well, you should be able to open another form on top of your current form to handle the login. You can set up events to pass information between your login form and your main form.

        That said, I know what you mean when you describe it as the WoW login form. Try designing both your login form and main forms as a UserControl object. When your program starts up, add the login control to the main form. When login is successful, pass a message to the parent control (ie, the main form) to tell it to remove the login control and put in the main gui controls.

        Something like this...

        Code:
        public void MyForm() { this.Controls.Add(new LoginControl()); }
        
        public void SuccessfullLoginEvent(object sender, EventArgs e)
        {
          this.Controls.Clear();
          this.Controls.Add(new MainGUIControl());
        }

        Comment

        Working...