home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 1996 August / VPR9608A.BIN / del20try / install / data.z / MEMOAUTO.PAS < prev    next >
Pascal/Delphi Source File  |  1996-05-08  |  2KB  |  98 lines

  1. unit MemoAuto;
  2.  
  3. { This unit implements TMemoApp, the Application automation object class for
  4.   the MemoEdit application. TMemoApp is registered as a Single Instance
  5.   automation class, thus causing a new copy of the application to be run each
  6.   time an OLE Automation controller asks for an instance of the
  7.   "MemoEdit.Application" OLE class name. TMemoApp implements the following
  8.   automated methods and properties:
  9.  
  10.   function NewMemo: Variant;
  11.     Creates a new editor window and returns the window's automation object.
  12.  
  13.   function OpenMemo(const FileName: string): Variant;
  14.     Loads an existing file into a new editor window and returns the window's
  15.     automation object.
  16.  
  17.   procedure TileWindows;
  18.     Tiles all open editor windows.
  19.  
  20.   procedure CascadeWindows;
  21.     Cascades all open editor windows.
  22.  
  23.   property MemoCount: Integer;
  24.     Number of open editor windows.
  25.  
  26.   property Memos[Index: Integer]: Variant;
  27.     Array of automation objects for the currently open editor windows. }
  28.  
  29. interface
  30.  
  31. uses
  32.   OleAuto;
  33.  
  34. type
  35.   TMemoApp = class(TAutoObject)
  36.   private
  37.     function GetMemo(Index: Integer): Variant;
  38.     function GetMemoCount: Integer;
  39.   automated
  40.     procedure CascadeWindows;
  41.     function NewMemo: Variant;
  42.     function OpenMemo(const FileName: string): Variant;
  43.     procedure TileWindows;
  44.     property MemoCount: Integer read GetMemoCount;
  45.     property Memos[Index: Integer]: Variant read GetMemo;
  46.   end;
  47.  
  48. implementation
  49.  
  50. uses
  51.   MainFrm, EditFrm;
  52.  
  53. procedure TMemoApp.CascadeWindows;
  54. begin
  55.   MainForm.Cascade;
  56. end;
  57.  
  58. function TMemoApp.GetMemo(Index: Integer): Variant;
  59. begin
  60.   Result := TEditForm(MainForm.MDIChildren[Index]).OleObject;
  61. end;
  62.  
  63. function TMemoApp.GetMemoCount: Integer;
  64. begin
  65.   Result := MainForm.MDIChildCount;
  66. end;
  67.  
  68. function TMemoApp.NewMemo: Variant;
  69. begin
  70.   Result := MainForm.CreateMemo('').OleObject;
  71. end;
  72.  
  73. function TMemoApp.OpenMemo(const FileName: string): Variant;
  74. begin
  75.   Result := MainForm.CreateMemo(FileName).OleObject;
  76. end;
  77.  
  78. procedure TMemoApp.TileWindows;
  79. begin
  80.   MainForm.Tile;
  81. end;
  82.  
  83. procedure RegisterMemoApp;
  84. const
  85.   AutoClassInfo: TAutoClassInfo = (
  86.     AutoClass: TMemoApp;
  87.     ProgID: 'MemoEdit.Application';
  88.     ClassID: '{F7FF4880-200D-11CF-BD2F-0020AF0E5B81}';
  89.     Description: 'Memo Editor Application';
  90.     Instancing: acSingleInstance);
  91. begin
  92.   Automation.RegisterClass(AutoClassInfo);
  93. end;
  94.  
  95. initialization
  96.   RegisterMemoApp;
  97. end.
  98.