home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / misc / objects / winchild / main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-21  |  1.0 KB  |  55 lines

  1. unit Main;
  2.  
  3. { Program copyright (c) 1995 by Charles Calvert }
  4. { Project Name: WINCHILD }
  5.  
  6. { An exercise in creating a child form dynamically
  7.   at run time. }
  8.  
  9. interface
  10.  
  11. uses
  12.   WinTypes, WinProcs,
  13.   Classes, Graphics,
  14.   Controls, Forms, StdCtrls, Menus;
  15.  
  16. type
  17.   TForm1 = class(TForm)
  18.     MainMenu1: TMainMenu;
  19.     Options1: TMenuItem;
  20.     CreateForm1: TMenuItem;
  21.     CreateButton1: TMenuItem;
  22.     procedure Button1Click(Sender: TObject);
  23.     procedure Button2Click(Sender: TObject);
  24.   private
  25.     MyWindow: TForm;
  26.   end;
  27.  
  28. var
  29.   Form1: TForm1;
  30.  
  31. implementation
  32.  
  33. {$R *.DFM}
  34.  
  35. procedure TForm1.Button1Click(Sender: TObject);
  36. begin
  37.   MyWindow := TForm.Create(Application);
  38.   MyWindow.Parent := Form1;
  39.   MyWindow.Visible := True;
  40.   TMenuItem(Sender).Enabled := False;
  41.   CreateButton1.Enabled := True;
  42. end;
  43.  
  44. procedure TForm1.Button2Click(Sender: TObject);
  45. var
  46.   MyButton: TButton;
  47. begin
  48.   MyButton := TButton.Create(Application);
  49.   MyButton.Parent := MyWindow;
  50.   MyButton.Caption := 'Dynamic';
  51.   MyButton.Show;
  52. end;
  53.  
  54. end.
  55.