I have a bunch of forms and I want to automate them so they would open and close by themselves.
I know how to get them to open (by having an OnActivate function), but I'm having trouble closing them.
So, for example, I have
procedure TProgressForm.FormActivate(Sender: TObject);
begin
inherited;
if FModItem.IsInQueue then
begin
RunBtnClick(Self);
ModalResult := mrOK;
end;
end;
which runs a function. I want to close the window after the function has been run, which is what ModalResult should do.
(I've also tried adding the ModalResult line at the very end of the RunBtnClick procedure, but that didn't work either)
and I'm creating the form like this:
ProgForm := TProgressForm.Create(Self, FModItem);
Self.Visible := False;
try
if ProgForm.ShowModal = mrOK then
begin
Left := ProgForm.Left;
Top := ProgForm.Top;
end;
I've been able to create buttons to close the form just by adding mrOK to the Modal Result in Object Inspector, but I can't seem to do it explicitly
Can anyone see why it's not working?
Thanks
OnActivate
event handler? – Andreas Rejbrand