home *** CD-ROM | disk | FTP | other *** search
/ PC World Plus! (NZ) 2001 June / HDC50.iso / Runimage / Delphi50 / Objrepos / Mdiapp / MAIN.PAS < prev    next >
Pascal/Delphi Source File  |  1999-08-11  |  3KB  |  115 lines

  1. unit Main;
  2.  
  3. interface
  4.  
  5. uses Windows, SysUtils, Classes, Graphics, Forms, Controls, Menus,
  6.   StdCtrls, Dialogs, Buttons, Messages, ExtCtrls, ComCtrls, StdActns,
  7.   ActnList, ToolWin, ImgList;
  8.  
  9. type
  10.   TMainForm = class(TForm)
  11.     MainMenu1: TMainMenu;
  12.     File1: TMenuItem;
  13.     FileNewItem: TMenuItem;
  14.     FileOpenItem: TMenuItem;
  15.     FileCloseItem: TMenuItem;
  16.     Window1: TMenuItem;
  17.     Help1: TMenuItem;
  18.     N1: TMenuItem;
  19.     FileExitItem: TMenuItem;
  20.     WindowCascadeItem: TMenuItem;
  21.     WindowTileItem: TMenuItem;
  22.     WindowArrangeItem: TMenuItem;
  23.     HelpAboutItem: TMenuItem;
  24.     OpenDialog: TOpenDialog;
  25.     FileSaveItem: TMenuItem;
  26.     FileSaveAsItem: TMenuItem;
  27.     Edit1: TMenuItem;
  28.     CutItem: TMenuItem;
  29.     CopyItem: TMenuItem;
  30.     PasteItem: TMenuItem;
  31.     WindowMinimizeItem: TMenuItem;
  32.     StatusBar: TStatusBar;
  33.     ActionList1: TActionList;
  34.     EditCut1: TEditCut;
  35.     EditCopy1: TEditCopy;
  36.     EditPaste1: TEditPaste;
  37.     FileNew1: TAction;
  38.     FileSave1: TAction;
  39.     FileExit1: TAction;
  40.     FileOpen1: TAction;
  41.     FileSaveAs1: TAction;
  42.     WindowCascade1: TWindowCascade;
  43.     WindowTileHorizontal1: TWindowTileHorizontal;
  44.     WindowArrangeAll1: TWindowArrange;
  45.     WindowMinimizeAll1: TWindowMinimizeAll;
  46.     HelpAbout1: TAction;
  47.     FileClose1: TWindowClose;
  48.     WindowTileVertical1: TWindowTileVertical;
  49.     WindowTileItem2: TMenuItem;
  50.     ToolBar2: TToolBar;
  51.     ToolButton1: TToolButton;
  52.     ToolButton2: TToolButton;
  53.     ToolButton3: TToolButton;
  54.     ToolButton4: TToolButton;
  55.     ToolButton5: TToolButton;
  56.     ToolButton6: TToolButton;
  57.     ToolButton9: TToolButton;
  58.     ToolButton7: TToolButton;
  59.     ToolButton8: TToolButton;
  60.     ToolButton10: TToolButton;
  61.     ToolButton11: TToolButton;
  62.     ImageList1: TImageList;
  63.     procedure FileNew1Execute(Sender: TObject);
  64.     procedure FileOpen1Execute(Sender: TObject);
  65.     procedure HelpAbout1Execute(Sender: TObject);
  66.     procedure FileExit1Execute(Sender: TObject);
  67.   private
  68.     { Private declarations }
  69.     procedure CreateMDIChild(const Name: string);
  70.   public
  71.     { Public declarations }
  72.   end;
  73.  
  74. var
  75.   MainForm: TMainForm;
  76.  
  77. implementation
  78.  
  79. {$R *.DFM}
  80.  
  81. uses ChildWin, About;
  82.  
  83. procedure TMainForm.CreateMDIChild(const Name: string);
  84. var
  85.   Child: TMDIChild;
  86. begin
  87.   { create a new MDI child window }
  88.   Child := TMDIChild.Create(Application);
  89.   Child.Caption := Name;
  90.   if FileExists(Name) then Child.Memo1.Lines.LoadFromFile(Name);
  91. end;
  92.  
  93. procedure TMainForm.FileNew1Execute(Sender: TObject);
  94. begin
  95.   CreateMDIChild('NONAME' + IntToStr(MDIChildCount + 1));
  96. end;
  97.  
  98. procedure TMainForm.FileOpen1Execute(Sender: TObject);
  99. begin
  100.   if OpenDialog.Execute then
  101.     CreateMDIChild(OpenDialog.FileName);
  102. end;
  103.  
  104. procedure TMainForm.HelpAbout1Execute(Sender: TObject);
  105. begin
  106.   AboutBox.ShowModal;
  107. end;
  108.  
  109. procedure TMainForm.FileExit1Execute(Sender: TObject);
  110. begin
  111.   Close;
  112. end;
  113.  
  114. end.
  115.