Re: [D7 Newbie] Exception while closing busy file
- From: "Bruce Roberts" <ber@xxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 20 Sep 2005 15:27:50 -0400
"Pascal" <pascal.negre@xxxxxxxxxxxx> wrote in message
news:aekji15ps7tbbhb979iip7mff216rt7195@xxxxxxxxxx
> I'm still pretty wet behind the ears when it comes to Delphi,
> so the problem below might be very simple to solve for more
> experienced Delphi developers.
>
> I'd like to show a form with a push button to launch an operation. But
> the same button should then be available to stop and close the
> application:
It would be simpler if you used multiple buttons, but the logic is
essentially similar. You need to make sure that the code to stop the run and
that to close the application takes into account the fact that the i/o
operation may be in progress. You also need to insure that i/o operations
terminates in an appropriate manner. Use some flags
Type
tForm1 = class (tForm)
. . .
private
fStopRun,
fCloseApp : boolean;
. . .
end;
procedure tForm1.Button1Click (Sender : tObject);
begin
if Button1.Caption = 'Run'
then begin
fStopRun := False;
fCloseApp := False;
// start the run
while (not fStopRun) and (not fCloseApp) and YourCondition do
begin
. . .
Application.ProcessMessages;
end;
// clean up
end
else begin
fStopRun := Button1.Caption = 'Stop';
fCloseApp := Button1.Caption := 'Close';
end;
end;
.
- Follow-Ups:
- Re: [D7 Newbie] Exception while closing busy file
- From: Pascal
- Re: [D7 Newbie] Exception while closing busy file
- References:
- [D7 Newbie] Exception while closing busy file
- From: Pascal
- [D7 Newbie] Exception while closing busy file
- Prev by Date: [D2005] IDE question
- Next by Date: Re: nasty SQL query, please advise...
- Previous by thread: [D7 Newbie] Exception while closing busy file
- Next by thread: Re: [D7 Newbie] Exception while closing busy file
- Index(es):