home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / Install / program files / Borland / BDS / 3.0 / Demos / Delphi.Net / VCL / MDI / MDIFrame.pas < prev   
Encoding:
Pascal/Delphi Source File  |  2004-10-22  |  3.7 KB  |  196 lines

  1. unit MDIFrame;
  2.  
  3. interface
  4.  
  5. uses
  6.      SysUtils, Windows, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, Menus;
  8.  
  9. type
  10.   TFrameForm = class(TForm)
  11.     MainMenu1: TMainMenu;
  12.     File1: TMenuItem;
  13.     New1: TMenuItem;
  14.     Open1: TMenuItem;
  15.     N1: TMenuItem;
  16.     Exit1: TMenuItem;
  17.     Window1: TMenuItem;
  18.     Tile1: TMenuItem;
  19.     Cascade1: TMenuItem;
  20.     Arrangeicons1: TMenuItem;
  21.     OpenFileDialog: TOpenDialog;
  22.     procedure Exit1Click(Sender: TObject);
  23.     procedure New1Click(Sender: TObject);
  24.     procedure Tile1Click(Sender: TObject);
  25.     procedure Cascade1Click(Sender: TObject);
  26.     procedure Arrangeicons1Click(Sender: TObject);
  27.     procedure Open1Click(Sender: TObject);
  28.   private
  29.     { Private declarations }
  30. {$IFDEF CLR}
  31.         procedure InitializeControls;
  32. {$ENDIF}
  33.   public
  34.     { Public declarations }
  35. {$IFDEF CLR}
  36.         constructor Create(AOwner: TComponent); override;
  37. {$ENDIF}
  38.   end;
  39.  
  40. var
  41.   FrameForm: TFrameForm;
  42.  
  43. implementation
  44.  
  45. uses
  46.      MDIEdit;
  47.  
  48. procedure TFrameForm.Exit1Click(Sender: TObject);
  49. begin
  50.   Close;
  51. end;
  52.  
  53. procedure TFrameForm.New1Click(Sender: TObject);
  54. begin
  55.   TEditForm.Create(Self);
  56. end;
  57.  
  58. procedure TFrameForm.Tile1Click(Sender: TObject);
  59. begin
  60.   Tile;
  61. end;
  62.  
  63. procedure TFrameForm.Cascade1Click(Sender: TObject);
  64. begin
  65.   Cascade;
  66. end;
  67.  
  68. procedure TFrameForm.Arrangeicons1Click(Sender: TObject);
  69. begin
  70.   ArrangeIcons;
  71. end;
  72.  
  73. procedure TFrameForm.Open1Click(Sender: TObject);
  74. begin
  75.   if OpenFileDialog.Execute then
  76.   with TEditForm.Create(Self) do
  77.     Open(OpenFileDialog.FileName);
  78. end;
  79.  
  80. {$IFDEF CLR}
  81. constructor TFrameForm.Create(AOwner: TComponent);
  82. begin
  83.     inherited CreateNew(AOwner);
  84.     InitializeControls;
  85. end;
  86. {$ENDIF}
  87. {$IFDEF CLR}
  88. procedure TFrameForm.InitializeControls;
  89. begin
  90.   // Initalizing all controls...
  91.     MainMenu1:= TMainMenu.Create(Self);
  92.     File1:= TMenuItem.Create(Self);
  93.     New1:= TMenuItem.Create(Self);
  94.     Open1:= TMenuItem.Create(Self);
  95.     N1:= TMenuItem.Create(Self);
  96.     Exit1:= TMenuItem.Create(Self);
  97.     Window1:= TMenuItem.Create(Self);
  98.     Tile1:= TMenuItem.Create(Self);
  99.     Cascade1:= TMenuItem.Create(Self);
  100.     Arrangeicons1:= TMenuItem.Create(Self);
  101.     OpenFileDialog:= TOpenDialog.Create(Self);
  102.     
  103.     with MainMenu1 do
  104.     begin
  105.         Parent:= Self;
  106.     end;
  107.     
  108.     with File1 do
  109.     begin
  110.         MainMenu1.Items.Add(File1);
  111.         Caption:= '&File';
  112.     end;
  113.     
  114.     with New1 do
  115.     begin
  116.         File1.Add(New1);
  117.         Caption:= '&New';
  118.         OnClick:= New1Click;
  119.     end;
  120.     
  121.     with Open1 do
  122.     begin
  123.         File1.Add(Open1);
  124.         Caption:= '&Open...';
  125.         OnClick:= Open1Click;
  126.     end;
  127.     
  128.     with N1 do
  129.     begin
  130.         File1.Add(N1);
  131.         Caption:= '-';
  132.     end;
  133.     
  134.     with Exit1 do
  135.     begin
  136.         File1.Add(Exit1);
  137.         Caption:= 'E&xit';
  138.         GroupIndex:= 9;
  139.         OnClick:= Exit1Click;
  140.     end;
  141.     
  142.     with Window1 do
  143.     begin
  144.         MainMenu1.Items.Add(Window1);
  145.         Caption:= '&Window';
  146.         GroupIndex:= 9;
  147.     end;
  148.     
  149.     with Tile1 do
  150.     begin
  151.         Window1.Add(Tile1);
  152.         Caption:= '&Tile';
  153.         OnClick:= Tile1Click;
  154.     end;
  155.     
  156.     with Cascade1 do
  157.     begin
  158.         Window1.Add(Cascade1);
  159.         Caption:= '&Cascade';
  160.         OnClick:= Cascade1Click;
  161.     end;
  162.     
  163.     with Arrangeicons1 do
  164.     begin
  165.         Window1.Add(Arrangeicons1);
  166.         Caption:= '&Arrange icons';
  167.         OnClick:= Arrangeicons1Click;
  168.     end;
  169.     
  170.     with OpenFileDialog do
  171.     begin
  172.         Parent:= Self;
  173.         Filter:=  'Rich text files (*.rtf)|*.rtf|Plain text files (*.txt)|*.txt|All' +
  174.           ' files|*.*';
  175.     end;
  176.  
  177.     // Form's PMEs'
  178.     Left:= 875;
  179.     Top:= 501;
  180.     Width:= 435;
  181.     Height:= 300;
  182.     Caption:= 'Text editor';
  183.     Color:= clBtnFace;
  184.     Font.Charset:= DEFAULT_CHARSET;
  185.     Font.Color:= clWindowText;
  186.     Font.Height:= -11;
  187.     Font.Name:= 'MS Sans Serif';
  188.     Font.Style:= [];
  189.     FormStyle:= fsMDIForm;
  190.     Menu:= MainMenu1;
  191.     Position:= poDefault;
  192.     WindowMenu:= Window1;
  193. end;
  194. {$ENDIF}
  195. end.
  196.