Click here to Skip to main content
15,889,992 members
Home / Discussions / C#
   

C#

 
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 
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 
Natural_Demon wrote:
doesn't work, the class gets disposed after the login screen gets closed


I think that is correct.

There probably are many ways to achieve what you want. Here are two ways I would try:

1. Use a modal dialog for the login stuff; this is the logical approach as I assume the MainForm isn't going to do any useful work if you're not logged in. Use the DialogResult value to indicate success.
Modal dialogs need disposing, so a using statement is used.

bool loggedIn=false;
using (LoginForm lf=new LoginForm()) loggedIn=lf.ShowDialog()==DialogResult.OK;
if (loggedIn) Application.Run(new MainForm());


2. However if MainForm could do useful things while user is looking around/typing name&password:

MainForm mf=new MainForm();   // constructor can launch thread to perform some harmless work; nothing shows yet.
bool loggedIn=false;
using (LoginForm lf=new LoginForm()) loggedIn=lf.ShowDialog()==DialogResult.OK;
if (loggedIn) Application.Run(mf);  //the implicit mf.Show() will cause Load and Shown events


Smile | :)

Luc Pattyn [Forum Guidelines] [My Articles]

The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.

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 
GeneralRe: Sending a connection to another computer in a PEER TO PEER network Pin
CoderForEver26-Aug-09 3:40
CoderForEver26-Aug-09 3:40 
GeneralRe: Sending a connection to another computer in a PEER TO PEER network Pin
Richard MacCutchan26-Aug-09 6:21
mveRichard MacCutchan26-Aug-09 6:21 
GeneralRe: Sending a connection to another computer in a PEER TO PEER network Pin
CoderForEver26-Aug-09 10:35
CoderForEver26-Aug-09 10:35 
GeneralRe: Sending a connection to another computer in a PEER TO PEER network Pin
Richard MacCutchan26-Aug-09 21:23
mveRichard MacCutchan26-Aug-09 21:23 

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.