home *** CD-ROM | disk | FTP | other *** search
- unit Main;
-
- { Program copyright (c) 1995 by Charles Calvert }
- { Project Name: WINCHILD }
-
- { An exercise in creating a child form dynamically
- at run time. }
-
- interface
-
- uses
- WinTypes, WinProcs,
- Classes, Graphics,
- Controls, Forms, StdCtrls, Menus;
-
- type
- TForm1 = class(TForm)
- MainMenu1: TMainMenu;
- Options1: TMenuItem;
- CreateForm1: TMenuItem;
- CreateButton1: TMenuItem;
- procedure Button1Click(Sender: TObject);
- procedure Button2Click(Sender: TObject);
- private
- MyWindow: TForm;
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- procedure TForm1.Button1Click(Sender: TObject);
- begin
- MyWindow := TForm.Create(Application);
- MyWindow.Parent := Form1;
- MyWindow.Visible := True;
- TMenuItem(Sender).Enabled := False;
- CreateButton1.Enabled := True;
- end;
-
- procedure TForm1.Button2Click(Sender: TObject);
- var
- MyButton: TButton;
- begin
- MyButton := TButton.Create(Application);
- MyButton.Parent := MyWindow;
- MyButton.Caption := 'Dynamic';
- MyButton.Show;
- end;
-
- end.
-