[Lazarus] Exception when re-opening a modal dialogue
Mattias Gaertner
nc-gaertnma at netcologne.de
Mon Feb 11 15:27:46 CET 2013
On Mon, 11 Feb 2013 09:19:58 -0500
Timothy Groves <the.tail.kinker at gmail.com> wrote:
> So when I call TfrmNewChapter.ShowModal, it works the first time. But
> when I call it the second time, I get an exception. The form is closed
> with the OK or Cancel buttons; their methods are given below. What am
> I doing wrong?
>
>
> procedure TfrmNewChapter.btnCancelClick(Sender: TObject);
> begin
> txtChapterTitle.Text := '';
> frmNewChapter.Hide;
Do not hide the form yourself. That's done by ShowModal.
Set the ModalResult.
ModalResult:=mrCancel;
> end;
>
> procedure TfrmNewChapter.btnOKClick(Sender: TObject);
> var
> s : string;
> begin
> if (txtChapterTitle.Text <> '') then begin
> NewChapter (txtChapterTitle.Text);
> txtChapterTitle.Text := '';
> str (ChapterCount, s);
> while (length (s) < 4) do
> s := '0' + s;
> Chapter^.Filename := Story^.ShortName + s;
> PopulateChapterList;
> frmNewChapter.Hide;
ModalResult:=mrOk;
> MarkChapterListDirty;
> end;
> end;
Mattias
More information about the Lazarus
mailing list