Click here to Skip to main content
15,912,329 members
Home / Discussions / C#
   

C#

 
Questionquestion about SetResolution of bitmap Pin
abstar26-Jan-07 18:28
abstar26-Jan-07 18:28 
AnswerRe: question about SetResolution of bitmap Pin
Christian Graus26-Jan-07 21:38
protectorChristian Graus26-Jan-07 21:38 
QuestionExit a WinForm application at initialization Pin
Glen Harvy26-Jan-07 17:44
Glen Harvy26-Jan-07 17:44 
AnswerRe: Exit a WinForm application at initialization Pin
Syed Muhammad Kamran26-Jan-07 21:21
Syed Muhammad Kamran26-Jan-07 21:21 
GeneralRe: Exit a WinForm application at initialization Pin
Glen Harvy26-Jan-07 22:25
Glen Harvy26-Jan-07 22:25 
GeneralRe: Exit a WinForm application at initialization Pin
Syed Muhammad Kamran26-Jan-07 22:52
Syed Muhammad Kamran26-Jan-07 22:52 
GeneralRe: Exit a WinForm application at initialization Pin
Glen Harvy26-Jan-07 23:14
Glen Harvy26-Jan-07 23:14 
GeneralRe: Exit a WinForm application at initialization Pin
Stefan Troschuetz27-Jan-07 0:17
Stefan Troschuetz27-Jan-07 0:17 
Application.Exit will nit work inside the constructor, because Application.Run wasn't executed yet. If you look at the static Main method of your application it looks similar to this:
static void Main()
{
  Applivation.Run(new MainForm());
}

So what happens, is that an instance of the MainForm class is created (calling your constructor) and afterwards passed to the Application.Run method. That's why Application.Exit does not work inside the constructor.
It would probably be the best to assign the instance of MainForm to a variable and only call Application.Run, if your MainForm could be properly initialized:
static void Main()
{
  MainForm form = new MainForm();
  if (something)
  {
    Applivation.Run(form);
  } 
  else
  {
    Show some kind of error message
  }
}



"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

www.troschuetz.de

GeneralRe: Exit a WinForm application at initialization Pin
Glen Harvy27-Jan-07 0:55
Glen Harvy27-Jan-07 0:55 
GeneralRe: Exit a WinForm application at initialization Pin
Stefan Troschuetz27-Jan-07 1:06
Stefan Troschuetz27-Jan-07 1:06 
Questionfaq Pin
Ashutosh Kumar Gupta26-Jan-07 17:10
Ashutosh Kumar Gupta26-Jan-07 17:10 
AnswerRe: faq Pin
quiteSmart26-Jan-07 20:01
quiteSmart26-Jan-07 20:01 
AnswerRe: faq Pin
Syed Muhammad Kamran26-Jan-07 21:25
Syed Muhammad Kamran26-Jan-07 21:25 
AnswerRe: faq Pin
Christian Graus26-Jan-07 21:39
protectorChristian Graus26-Jan-07 21:39 
QuestionNeed help with loan interest calculation Pin
apricotsun26-Jan-07 16:12
apricotsun26-Jan-07 16:12 
AnswerRe: Need help with loan interest calculation Pin
Glen Harvy26-Jan-07 18:11
Glen Harvy26-Jan-07 18:11 
GeneralRe: Need help with loan interest calculation Pin
apricotsun27-Jan-07 2:55
apricotsun27-Jan-07 2:55 
QuestionRun client-side web scripts in-memory? Pin
Jasmine250126-Jan-07 13:58
Jasmine250126-Jan-07 13:58 
Question.Net Reactor Pin
Glen Harvy26-Jan-07 13:52
Glen Harvy26-Jan-07 13:52 
QuestionMake a wrapped win32-dialog modal Pin
AlexZieg7126-Jan-07 12:45
AlexZieg7126-Jan-07 12:45 
AnswerRe: Make a wrapped win32-dialog modal Pin
Christian Graus26-Jan-07 13:23
protectorChristian Graus26-Jan-07 13:23 
GeneralRe: Make a wrapped win32-dialog modal Pin
AlexZieg7126-Jan-07 22:47
AlexZieg7126-Jan-07 22:47 
AnswerRe: Make a wrapped win32-dialog modal Pin
AlexZieg7127-Jan-07 3:37
AlexZieg7127-Jan-07 3:37 
QuestionFinding word in textbox Pin
conemajstor26-Jan-07 10:26
conemajstor26-Jan-07 10:26 
AnswerRe: Finding word in textbox Pin
Christian Graus26-Jan-07 10:33
protectorChristian Graus26-Jan-07 10:33 

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.