home *** CD-ROM | disk | FTP | other *** search
/ Delphi 4 Bible / Delphi_4_Bible_Tom_Swan_IDG_Books_1998.iso / source / ADDPAGE / MAIN.PAS < prev   
Pascal/Delphi Source File  |  1998-04-13  |  1KB  |  56 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, Windows, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Buttons, StdCtrls, TabNotBk, ComCtrls;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     TabbedNotebook1: TTabbedNotebook;
  12.     AddPageButton: TButton;
  13.     CloseBitBtn: TBitBtn;
  14.     AddControlButton: TButton;
  15.     procedure AddPageButtonClick(Sender: TObject);
  16.     procedure AddControlButtonClick(Sender: TObject);
  17.   private
  18.     { Private declarations }
  19.   public
  20.     { Public declarations }
  21.   end;
  22.  
  23. var
  24.   MainForm: TMainForm;
  25.  
  26. implementation
  27.  
  28. {$R *.DFM}
  29.  
  30. {- Insert new page into TabbedNotebook }
  31. procedure TMainForm.AddPageButtonClick(Sender: TObject);
  32. begin
  33.   with TabbedNotebook1 do
  34.     Pages.Add(Format('Page %d',[Pages.Count-1]));
  35. end;
  36.  
  37. {- Insert new control into current page }
  38. procedure TMainForm.AddControlButtonClick(Sender: TObject);
  39. var
  40.   L: TListBox;
  41.   P: TWinControl;
  42. begin
  43.   L := TListBox.Create(Self);
  44.   with TabbedNotebook1 do
  45.   begin
  46.     P := Pages.Objects[PageIndex] as TWinControl;
  47.     L.Parent := P;
  48.     L.SetBounds(10, 10, 100, 100);
  49. {- Insert page tab label into edit control for demonstration.
  50.    You don't have to perform this step. }
  51.     L.Items.Add(TTabPage(P).Caption);
  52.   end;
  53. end;
  54.  
  55. end.
  56.