Recent

Author Topic: Forms in Tabs  (Read 8705 times)

andrejsilva

  • New Member
  • *
  • Posts: 14
Forms in Tabs
« on: August 07, 2009, 02:21:36 pm »
I am trying to work using tabs, the code following this operation and creating the flaps, but I am having problems with the event OnExit components that flaps when the event is not triggered, the event OnEnter works normally.

These are the codes used to create the tabs using TPageControl.

Code: [Select]
procedure TfrmPrincipal.CriarAba(clsForm: TFormClass; Index: Integer);
var
  TabSheet: TTabSheet;
  Form: TForm;
begin

  TabSheet := TTabSheet.Create(Self);
  Form := clsForm.Create(TabSheet);

  if AbaExiste(Form.Caption) then
    Exit;

  with TabSheet do
  begin
    PageControl := PageControl1;
    Caption := Form.Caption;
    ImageIndex := Index;
  end;

  with Form do
  begin
    Align := alClient;
    BorderStyle := bsNone;
    Parent := TabSheet;
    Show;
  end;

  PageControl1.ActivePage := TabSheet;


end;

Code: [Select]
function TfrmPrincipal.AbaExiste(NomeAba: string): Boolean;
var
  i: Integer;
  Aba: TTabSheet;
begin
  Result := False;
  for i := 0 to PageControl1.PageCount - 1 do
  begin
    if PageControl1.Pages[i].Caption = NomeAba then
    begin
      Aba := PageControl1.Pages[i];
      PageControl1.ActivePage := Aba;
      Result := True;
      break;
    end;
  end;
end;

Code: [Select]
procedure TfrmPrincipal.FecharAba(NomeAba: string);
var
  i: integer;
  Aba: TTabSheet;
begin
  for i := 0 to PageControl1.PageCount - 1 do
  begin
    if PageControl1.Pages[i].Caption = NomeAba then
    begin
      Aba := PageControl1.Pages[i];
      Aba.Destroy;
      PageControl1.ActivePageIndex := 0;
      break;
    end;
  end;
end;

 8)

jixian.yang

  • Full Member
  • ***
  • Posts: 173
Re: Forms in Tabs
« Reply #1 on: March 23, 2011, 06:50:41 am »
Quote
with Form do
  begin
    Align := alClient;
    BorderStyle := bsNone;
    Parent := TabSheet;
    Show;
  end;
On win32
ParentWindow := TabSheet.Handle;