Click here to Skip to main content
15,887,464 members
Home / Discussions / C#
   

C#

 
AnswerRe: Is there a terminal services friendly way of writing this code? Pin
Daniel Grunwald20-Aug-09 12:47
Daniel Grunwald20-Aug-09 12:47 
Questionthe proper way to make a login screen appear in the main class - Main() - program.cs Pin
Natural_Demon20-Aug-09 11:04
Natural_Demon20-Aug-09 11:04 
AnswerRe: the proper way to make a login screen appear in the main class - Main() - program.cs Pin
CoderForEver20-Aug-09 11:21
CoderForEver20-Aug-09 11:21 
GeneralRe: the proper way to make a login screen appear in the main class - Main() - program.cs Pin
Natural_Demon20-Aug-09 12:15
Natural_Demon20-Aug-09 12:15 
AnswerRe: the proper way to make a login screen appear in the main class - Main() - program.cs Pin
PIEBALDconsult20-Aug-09 12:00
mvePIEBALDconsult20-Aug-09 12:00 
GeneralRe: the proper way to make a login screen appear in the main class - Main() - program.cs Pin
Natural_Demon20-Aug-09 12:25
Natural_Demon20-Aug-09 12:25 
GeneralRe: the proper way to make a login screen appear in the main class - Main() - program.cs Pin
PIEBALDconsult20-Aug-09 13:00
mvePIEBALDconsult20-Aug-09 13:00 
GeneralRe: the proper way to make a login screen appear in the main class - Main() - program.cs Pin
Natural_Demon20-Aug-09 13:58
Natural_Demon20-Aug-09 13:58 
// program.cs
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace Modales_window
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new loginscreen.LoginScreen());
            if (loginscreen.LoginScreen.Succeeded)
            {
                Application.Run(new Form1());
            }
            else
            {
                Application.Exit();
            }
        }
    }
}


LoginScreen.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace loginscreen
{
    public partial class LoginScreen : Form
    {
        static public bool Succeeded = false;
        public LoginScreen()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Succeeded = true;     
            this.Close();
        }
    }
}


this seams to do the job perfectly.
if you click the button in the login screen, the bool gets set to true
and the windows gets closed with
this.Close();,
making the main Form appear, if you close the login form with the RED X, the application closes.

: )

i tried your sollution, but a normal
public bool Succeeded = false;
in combination of
Loginscreen.LoginScreen login = new Loginscreen.LoginScreen() ;
doesn't work, the class gets disposed after the login screen gets closed and
public bool Succeeded = true; gets lost/disposed and the application exit's.

after a litle thinking, i tried to make it static and without the creation of an instance of the login class.


1 more question, ....
what happens with Application.Run(new loginscreen.LoginScreen()); after the login screen gets closed by this.Close(); or the RED X?

Bad = knowing 2 much

GeneralRe: the proper way to make a login screen appear in the main class - Main() - program.cs Pin
Henry Minute20-Aug-09 14:15
Henry Minute20-Aug-09 14:15 
GeneralRe: the proper way to make a login screen appear in the main class - Main() - program.cs Pin
Natural_Demon20-Aug-09 14:36
Natural_Demon20-Aug-09 14:36 
GeneralRe: the proper way to make a login screen appear in the main class - Main() - program.cs Pin
Henry Minute20-Aug-09 14:47
Henry Minute20-Aug-09 14:47 
GeneralRe: the proper way to make a login screen appear in the main class - Main() - program.cs Pin
Luc Pattyn20-Aug-09 14:32
sitebuilderLuc Pattyn20-Aug-09 14:32 
GeneralRe: the proper way to make a login screen appear in the main class - Main() - program.cs Pin
Natural_Demon20-Aug-09 15:03
Natural_Demon20-Aug-09 15:03 
QuestionOpen a prog/firefox ever x sec! Pin
nhqlbaislwfiikqraqnm20-Aug-09 10:27
nhqlbaislwfiikqraqnm20-Aug-09 10:27 
AnswerRe: Open a prog/firefox ever x sec! Pin
EliottA20-Aug-09 10:36
EliottA20-Aug-09 10:36 
GeneralRe: Open a prog/firefox ever x sec! Pin
nhqlbaislwfiikqraqnm20-Aug-09 10:42
nhqlbaislwfiikqraqnm20-Aug-09 10:42 
AnswerRe: Open a prog/firefox ever x sec! Pin
PIEBALDconsult20-Aug-09 12:01
mvePIEBALDconsult20-Aug-09 12:01 
QuestionSending a connection to another computer in a PEER TO PEER network Pin
CoderForEver20-Aug-09 10:23
CoderForEver20-Aug-09 10:23 
AnswerRe: Sending a connection to another computer in a PEER TO PEER network Pin
EliottA20-Aug-09 10:37
EliottA20-Aug-09 10:37 
GeneralRe: Sending a connection to another computer in a PEER TO PEER network Pin
CoderForEver20-Aug-09 10:55
CoderForEver20-Aug-09 10:55 
GeneralRe: Sending a connection to another computer in a PEER TO PEER network Pin
EliottA21-Aug-09 2:51
EliottA21-Aug-09 2:51 
GeneralRe: Sending a connection to another computer in a PEER TO PEER network Pin
CoderForEver21-Aug-09 6:21
CoderForEver21-Aug-09 6:21 
GeneralRe: Sending a connection to another computer in a PEER TO PEER network Pin
Richard MacCutchan25-Aug-09 10:34
mveRichard MacCutchan25-Aug-09 10:34 
GeneralRe: Sending a connection to another computer in a PEER TO PEER network Pin
CoderForEver26-Aug-09 1:56
CoderForEver26-Aug-09 1:56 
GeneralRe: Sending a connection to another computer in a PEER TO PEER network Pin
Richard MacCutchan26-Aug-09 3:12
mveRichard MacCutchan26-Aug-09 3:12 

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.