John Barrat wrote: > I have a form which is there simply to report progress - it has a > progressbar on it.
That's not all it's there for. It's also there to delete files. The name you've given the form is misleading; it suggests that all it does it report progress when in fact it also _makes_ progress. > This is how I am calling it: > > procedure TfmCleanUpMain.btnOKClick(Sender: TObject); > begin > if fmprogress.showmodal <> mrNone then > close; > end; Under what circumstances would your form's ShowModal method return mrNone? > On its return I close the application. Unless the modal result is mrNone. Then what happens? > I do all the work on the progress form in the OnActivate event. - this may > be my problem but I don't know a way around it as there is no user > interaction with the form. OnActivate occurs when the form receives focus -- every time. Focus is necessarily a user-interaction event; it dictates where the user's actions will be directed. > My FormActivate code is shown below. Although I set the modal result to > mrOK the form fails to close. > > procedure TfmProgress.FormActivate(Sender: TObject); > Var i: Integer; > begin > FindFilesToDelete; > ProgressBar1.Max := FileList.Count; > ProgressBar1.Min := 0; > ProgressBar1.Position := ProgressBar1.Max; > For i := 0 to FileList.Count -1 do > begin > Label1.Caption := '"'+ ExtractRelativePath(IDEPath,FileList[i]) + '"'; > if DeleteFile(FileList[i])then > ProgressBar1.Position := ProgressBar1.Position - 1; > end; > Label1.Caption := 'Done'; > fmProgress.ModalResult := mrOK; > end; > > Can anyone suggest a solution? Use the debugger to step through your program and determine why the form isn't closing. Your unstated assumption is that setting ModalResult will close the form. In general, that's true. Step through to determine why it isn't true in this case. It probably has something to do with when the OnActivate event occurs in relation to the rest of the modal loop. You'll need to have the "debug DCUs" option enabled. -- Rob _______________________________________________ Delphi mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi

