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

C#

 
GeneralRe: LoadPostData Error Pin
ceetee5-May-08 7:12
ceetee5-May-08 7:12 
Questiondisable taskmanager Pin
False Chicken5-May-08 5:03
False Chicken5-May-08 5:03 
AnswerRe: disable taskmanager Pin
tgrt5-May-08 5:42
tgrt5-May-08 5:42 
AnswerRe: disable taskmanager Pin
Dave Kreskowiak5-May-08 6:48
mveDave Kreskowiak5-May-08 6:48 
AnswerRe: disable taskmanager Pin
Giorgi Dalakishvili5-May-08 8:07
mentorGiorgi Dalakishvili5-May-08 8:07 
AnswerRe: disable taskmanager Pin
PIEBALDconsult5-May-08 8:44
mvePIEBALDconsult5-May-08 8:44 
QuestionAdd login form to a program? Pin
daden2035-May-08 4:48
daden2035-May-08 4:48 
AnswerRe: Add login form to a program? Pin
carbon_golem5-May-08 6:51
carbon_golem5-May-08 6:51 
**DISCLAIMER** This may or may not be the best way to accomplish this task. This code is based on this article.[^]

static class Program {
       /// <summary>
       /// The main entry point for the application.
       /// </summary>
       [STAThread]
       static void Main() {
           Application.EnableVisualStyles();
           Application.SetCompatibleTextRenderingDefault(false);
           LoginApplicationContext loctx = new LoginApplicationContext(new Form1(), new LogIn());
           Application.Run(loctx);
       }
   }

   public class LoginApplicationContext : ApplicationContext {

       private Form appForm;

       public LoginApplicationContext(Form app, Form login)
           : base(login) {
           appForm = app;
       }

       protected override void OnMainFormClosed(object sender, EventArgs e) {
           if (sender is LogIn) {
               if ((sender as LogIn).DialogResult == DialogResult.OK) {
                   base.MainForm = this.appForm;
                   base.MainForm.Show();
               } else {
                   Application.Exit();
               }
           } else if (sender is Form1) {
               base.OnMainFormClosed(sender, e);
           }
       }

   }



In your login form you'll have to change the Form's DialogResult before you exit. I tested this and it seems to work, though again I don't know it it's the best approach.

Scott P

“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra

Questionhow I know that which property is associated which file at run time. Pin
Guru Call5-May-08 4:47
Guru Call5-May-08 4:47 
QuestionRunning a form in a diferent Thread Pin
oscarderooij5-May-08 4:07
oscarderooij5-May-08 4:07 
AnswerRe: Running a form in a diferent Thread Pin
S. Senthil Kumar5-May-08 5:34
S. Senthil Kumar5-May-08 5:34 
GeneralRe: Running a form in a diferent Thread Pin
oscarderooij6-May-08 2:29
oscarderooij6-May-08 2:29 
GeneralRe: Running a form in a diferent Thread Pin
S. Senthil Kumar6-May-08 2:54
S. Senthil Kumar6-May-08 2:54 
GeneralRe: Running a form in a diferent Thread Pin
oscarderooij13-May-08 3:27
oscarderooij13-May-08 3:27 
AnswerRe: Running a form in a diferent Thread Pin
Luc Pattyn5-May-08 7:19
sitebuilderLuc Pattyn5-May-08 7:19 
GeneralRe: Running a form in a diferent Thread Pin
oscarderooij6-May-08 2:42
oscarderooij6-May-08 2:42 
GeneralRe: Running a form in a diferent Thread Pin
Luc Pattyn6-May-08 4:21
sitebuilderLuc Pattyn6-May-08 4:21 
GeneralRe: Running a form in a diferent Thread Pin
oscarderooij13-May-08 3:25
oscarderooij13-May-08 3:25 
GeneralRe: Running a form in a diferent Thread Pin
Luc Pattyn13-May-08 3:45
sitebuilderLuc Pattyn13-May-08 3:45 
GeneralRe: Running a form in a diferent Thread Pin
oscarderooij13-May-08 3:28
oscarderooij13-May-08 3:28 
GeneralRe: Running a form in a diferent Thread Pin
Luc Pattyn13-May-08 3:40
sitebuilderLuc Pattyn13-May-08 3:40 
GeneralRe: Running a form in a diferent Thread Pin
oscarderooij15-May-08 7:45
oscarderooij15-May-08 7:45 
QuestionForeach property in myClass Pin
Harvey Saayman5-May-08 3:57
Harvey Saayman5-May-08 3:57 
AnswerRe: Foreach property in myClass Pin
Colin Angus Mackay5-May-08 4:04
Colin Angus Mackay5-May-08 4:04 
AnswerRe: Foreach property in myClass Pin
S. Senthil Kumar5-May-08 4:06
S. Senthil Kumar5-May-08 4:06 

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.