Search code examples
delphidelphi-2007

How to call pop-up frame upon button click


I want to have a pop-up frame upon button click in 1 of my module, but I unable to get it. It always attached to my existing opened frame, my existing open frame layout will be overlap by this call out frame.

The follow are what I'm putting into coding:

procedure TWidgetFrame1.acBtnExecute(Sender: TObject);
begin
  inherited;
  WidgetFrame2 := TWidgetFrame2.Create(Owner);
  WidgetFrame2.Parent := TWinControl(Owner);
end;

Kindly need help on this~~~~ because this is the 1st time I'm using widget frame.


Solution

  • Set the frame's Parent to be its own popup TForm, not the Owner of the frame that is creating it.

    procedure TWidgetFrame1.acBtnExecute(Sender: TObject);
    var
      Frm: TForm;
    begin
      Frm := TForm.CreateNew(Owner);
      WidgetFrame2 := TWidgetFrame2.Create(Frm);
      WidgetFrame2.Parent := Frm;
      Frm.Show;
    end;