I have this simple routine which deletes a list of files contained in Memo1 that was previously built.
This works fine, except I want to show some form of progress.
As you can see I have a line to update a label caption in the loop, but that does not update until the end of the loop. The list can be pretty long, so it has the effect of hanging until finished.
Can someone suggest a better method please.
Steve (Delphi 2007 & XP)
This works fine, except I want to show some form of progress.
As you can see I have a line to update a label caption in the loop, but that does not update until the end of the loop. The list can be pretty long, so it has the effect of hanging until finished.
Can someone suggest a better method please.
Code:
procedure TSDIAppForm.Button3Click(Sender: TObject);
Var
Sure, Xpos, Ypos, count: integer;
DeleteFileName: string;
begin
Xpos := (Self{SDIAppForm}.Width Div 2) + Self{SDIAppForm}.Left - 120; //-120 to centre msgbox hor on form
Ypos := (Self{SDIAppForm}.Height Div 2) + Self{SDIAppForm}.Top - 50; //-50 to centre msgbox vert on form
// Show a confirmation dialog
Sure := MessageDlgPos('Are you certain you are REALLY REALLY sure?',mtCustom, [mbYes,mbCancel], 0, Xpos, Ypos);
if Sure = mrYes then
begin
for count := 0 to Memo1.Lines.Count-1 do
begin
DeleteFileName := Memo1.Lines[count];
Deleting.Caption := DeleteFileName;
DeleteFile(DeleteFileName);
end;
Memo1.Lines.Clear;
end;
end;
Steve (Delphi 2007 & XP)