From my application I wish to open a dialog, which should close immediately (after a short message) under some circumstances.
I've tried this:
procedure TForm2.FormActivate(Sender: TObject);
begin
if SomeCondition then
begin
ShowMessage('You can''t use this dialog right now.');
close;
modalresult := mrCancel;
end;
end;
but the dialog remains open. I've also tried to put the code in the OnShow event, but the result is the same.
Why doesn't this work?