2005年3月15日,发布于:
http://zyyang.spaces.live.com/blog/cns!193DAE30814DFA36!210.entry
- procedure TApplication.Run;
- begin
- FRunning := True; //I am Running.
- try
- AddExitProc(DoneApplication); //Add the current Application's Exit Proc Handler(Using AddExitProc()) so that DoneApplication is called when Exit.
- if FMainForm <> nil then //The first Form Application Creates.
- begin
- case CmdShow of
- SW_SHOWMINNOACTIVE: FMainForm.FWindowState := wsMinimized;
- SW_SHOWMAXIMIZED: MainForm.WindowState := wsMaximized;
- end;
- if FShowMainForm then
- if FMainForm.FWindowState = wsMinimized then
- Minimize else
- FMainForm.Visible := True;
- repeat
- try
- HandleMessage; //Messages Handling
- except
- HandleException(Self); //Exception
- end;
- until Terminated; //Application if told to shutdownn.
- end;
- finally
- FRunning := False; // Everything is over.
- end;
- end;