Reputation: 2128
I'm trying to do a simple program that will display a frame when a button on an other frame/form is clicked. To be more clear I want something like a MessageDialogBox but instead of a MessageDialogBox I want to display a frame.
What I've tried so far is this code on then OnClickEvent.
procedure TFrame3.SpeedButton1Click(Sender: TObject);
var
frm : TfrmVizorFunctii; // This is the frame I want to be appear;
begin
frm := TfrmVizorFunctii.Create(nil);
frm.Parent := nil;
frm.ABDBGrid1.ActiveColumn:=2;
frm.Left:=(Screen.Width-Width) div 2;
frm.Top:=(Screen.Height-Height) div 2;
frm.Show;
end;
What Am I doing wrong?
Upvotes: 0
Views: 3417
Reputation: 16612
You cannot display a frame without a parent. You must either set an existing form (or any TWinControl
on that form) as the parent, or create a new empty form and set that as the parent like so:
Form := TEmptyForm.Create (Application);
Frame := TMyFrame.Create (Form);
Frame.Parent := Form;
Frame.Align := alClient;
Form.Show;
That TEmptyForm
could have BorderStyle
set to bsNone
if you really only want to display the frame.
Upvotes: 7