Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cannot make a visible window modal

Status
Not open for further replies.

MLNorton

Programmer
Nov 15, 2009
134
US
I have a Main Form that calls another form:
Form_LettersDisplay.ShowModal;
Form_Letters contains a DBGrid and a Close Button.
When I close the FormLetters Form I get the following message:
“Cannot make a visible window modal”

What causes this and what is the solution?
 
Here is the entire code of the Form.

procedure TForm_LetterSent.FormActivate(Sender: TObject);
begin
Form_Main.RadioButton_LetterSent.Checked := false;
Form_Main.ADOTable1.Filter := '(MemLetter<>''-'') and (MemLetter <>''Sent'')';
Form_Main.ADOTable1.Filtered := true;
end;

procedure TForm_LetterSent.DBGrid1CellClick(Column: TColumn);
begin
Form_Main.ADOTable1.edit;
Form_Main.ADOTable1.FieldByName('MemLetter').AsString := 'Sent';
Form_Main.ADOTable1.post;
end;

procedure TForm_LetterSent.Button_CloseClick(Sender: TObject);
begin
Close;
end;
 
rather than calling 'Close' you should do

ModalResult := mrCancel;

which will close the form.

(you could also set the ModalResult property of the button to mrCancel and then you wouldn't need the event handler)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top