Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Windows Forms vs Dialog Application

Windows Forms vs Dialog Application

Scheduled Pinned Locked Moved C#
visual-studiowinformssecurityhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dubbele onzin
    wrote on last edited by
    #1

    Hi, I'm writing a simple application which requires the user to log on. It displays a logon form and if the user passes the security check, the main form is then displayed. On my logon form I have this:

    static void Main()
    {
    Application.Run(new Login());
    }

    If the user passes security, I want the logon form to close leaving the main form open but can I do this? I can hide the form but if I close the main form, the application is still running. Can anyone help? Thanks :)

    P 1 Reply Last reply
    0
    • D dubbele onzin

      Hi, I'm writing a simple application which requires the user to log on. It displays a logon form and if the user passes the security check, the main form is then displayed. On my logon form I have this:

      static void Main()
      {
      Application.Run(new Login());
      }

      If the user passes security, I want the logon form to close leaving the main form open but can I do this? I can hide the form but if I close the main form, the application is still running. Can anyone help? Thanks :)

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      The trick is to show the dialog before the Application.Run. Trust me - it works. What you end up with is something like this:

      static void Main()
      {
        using (Login login = new Login())
        {
          login.ShowDialog();
          if (login.IsAuthenticated)
          {
            Application.Run(new MainForm());
          }
        }
      }
      

      Of course, there are a couple of assumptions here. One is that your login form has an IsAuthenticated property, and the other is that your main form is called - well MainForm. Anyway, this should give you the general idea.

      Deja View - the feeling that you've seen this post before.

      My blog | My articles

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups