Halaman

Rabu, 16 Januari 2013

[Delphi] MDI On a TPanel, RTTI power example

Ummh, since it's 3 AM, and just as a quick note on delphi power, MDI child on a TPanel and an introduction to a RTTI usage..
You will need Delphi XE and TMS Component
procedure TForm1.AdvOfficeMDITabSet1TabClose(Sender: TObject;
  TabIndex: Integer; var Allow: Boolean);
var
  form : TForm;
begin
  form := AdvOfficeMDITabSet1.GetChildForm(AdvOfficeMDITabSet1.AdvOfficeTabs[TabIndex]);
  form.Close;
  Allow := False;
end;

procedure TForm1.New1Click(Sender: TObject);
var
  c : TForm;
begin
  c := TForm2.Create(Self);
  c.Parent := Panel2;
  c.SetBounds(0, 0, Panel2.Width, Panel2.Height);
  c.Caption := 'Yohan ' + IntToStr(Panel2.ControlCount);
  (c as TForm2).EllipsLabel1.Caption := c.Caption;
  c.Show;

  //introducing the power of delphi RTTI!
  if(c.ClassType = TForm2) then
    AdvOfficeMDITabSet1.AddTab(c);
end;


Tidak ada komentar:

Posting Komentar