Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing A Program after Create 1

Status
Not open for further replies.

PaidtheUmpire

Programmer
Jan 4, 2004
105
AU
What i want to do is once a user starts up the program...

it does the procedures it is supoosed to and then it i'll close itself.

Code:
procedure TForm1.FormCreate(Sender: TObject);
begin
  if paramcount > 0 then
    begin
      FileInput.Clear;
      FileInput.Lines.LoadFromFile(paramstr(1));
    end;
OutputMemo.Clear;
InputIntoGrid;
GridToGrid;
GridToOutput;
SaveTheOutput;
Close;
end;

It currently does everything and then sits there, not closed.

any ideas?

Delphi, Delphi, Delphi. Oi! Oi! Oi!
 
You'll have to terminate the application (ie insert the code [tt]Application.Terminate;[/tt]) rather than close the form if I understand you correctly.

Cheers,
Chris [pc2]
 
If using application.terminate then I would make sure that your data is being saved correctly.
I am wondering if the apparent 'hang' is due to the save not having completed for some reason.
application.terminate will do just that i.e. terminate the program immediatly.




[red]GNBM 4th Feb[/red] More on and other neat UK stuff at forum1091
Steve: Delphi a feersum engin indeed.
 
I beg to differ - from the help on TApplication, and the Application.Terminate help:
Terminate method (TApplication)
Ends application execution.

Delphi syntax:
procedure Terminate;

C++ syntax:
void __fastcall Terminate(void);

Description
Call Terminate to end the application programmatically. By calling Terminate rather than freeing the application object, you allow the application to shut down in an orderly fashion.

Terminate calls the Windows API PostQuitMessage function to perform an orderly shutdown of the application. Terminate is not immediate.

Terminate is called automatically on a WM_QUIT message and when the main form closes.

In my own apps, posts committed, files closed etc - no grief encountered [smile]


Cheers,
Chris [pc2]
 
Please see TonHu's answer here..
Its not the only one on this subject.
thread102-413414


[red]GNBM 4th Feb[/red] More on and other neat UK stuff at forum1091
Steve: Delphi a feersum engin indeed.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top