home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 March / Chip_1999-03_cd.bin / zkuste / delphi / D234C13 / RALIB.ZIP / RALib / Lib / Zoom.pas < prev   
Pascal/Delphi Source File  |  1998-08-15  |  3KB  |  118 lines

  1. {***********************************************************
  2.                 R&A Library
  3.        Copyright (C) 1996-98 R&A
  4.  
  5.        components  : none
  6.        description : Dephi IDE enhancement tool
  7.  
  8.        programer   : black
  9.        e-mail      : blacknbs@chat.ru
  10.        www         : www.chat.ru\~blacknbs\ralib
  11. ************************************************************}
  12.  
  13. {$INCLUDE RA.INC}
  14.  
  15. unit Zoom;
  16.  
  17. interface
  18.  
  19. uses
  20.   Windows,
  21.   ToolIntf, ExptIntf, VirtIntf, EditIntf,
  22.   Classes, Forms, Dialogs, Menus, SysUtils;
  23.  
  24.   procedure RegisterZoom;
  25.  
  26. implementation
  27.  
  28.  
  29. type
  30.   TEEditorZoom = class
  31.   private
  32.     procedure Zoom(Sender : TObject);
  33.   end;
  34.  
  35. procedure TEEditorZoom.Zoom(Sender : TObject);
  36. var
  37.   F : TForm;
  38.   i : integer;
  39. begin
  40.   F := Screen.ActiveForm;
  41.   if not F.ClassNameIs('TEditWindow') then begin
  42.     F := nil;
  43.     for i := 0 to Screen.FormCount - 1 do
  44.       if Screen.Forms[i].ClassNameIs('TEditWindow') then begin
  45.         F := Screen.Forms[i];
  46.         break;
  47.       end;
  48.   end;
  49.   if F <> nil then begin
  50.     if F.WindowState <> wsMaximized then
  51.       F.WindowState := wsMaximized
  52.     else
  53.       F.WindowState := wsNormal;
  54.   end;
  55. end;
  56.  
  57. procedure Unregister;
  58. var
  59.   F : TForm;
  60.   MenuItem : TMenuItem;
  61. begin
  62.   F := Application.FindComponent('AppBuilder') as TForm;
  63.   if F <> nil then begin
  64.     MenuItem := F.FindComponent('RAZoomEditor') as TMenuItem;
  65.     if MenuItem <> nil then MenuItem.Free;
  66.     MenuItem := F.FindComponent('RAZoomEditor2') as TMenuItem;
  67.     if MenuItem <> nil then MenuItem.Free;
  68.   end;
  69. end;
  70.  
  71. procedure RegisterZoom;
  72. var
  73.   F : TForm;
  74.   ViewsMenu, ViewNewEditorItem : TMenuItem;
  75.   MenuItem : TMenuItem;
  76.   Zoom : TEEditorZoom;
  77. begin
  78.   Unregister;
  79.   Zoom := nil; {avoid warning}
  80.   F := Application.FindComponent('AppBuilder') as TForm;
  81.   if F <> nil then
  82.   begin
  83.    // ShowMessage('Found AppBuilder');
  84.     ViewsMenu := F.FindComponent('ViewsMenu') as TMenuItem;
  85.     if ViewsMenu = nil then exit; {error}
  86.     MenuItem := TMenuItem.Create(F);
  87.     with MenuItem do
  88.     begin
  89.       Caption := 'Zoom Edit Window';
  90.       ShortCut := Menus.ShortCut(ord('Z'), [ssAlt]);
  91.       Name := 'RAZoomEditor';
  92.       OnClick := Zoom.Zoom;
  93.     end;
  94.     ViewNewEditorItem := F.FindComponent('ViewNewEditorItem') as TMenuItem;
  95.     if ViewNewEditorItem <> nil then
  96.       ViewsMenu.Insert(ViewNewEditorItem.MenuIndex+1, MenuItem)
  97.     else
  98.       ViewsMenu.Add(MenuItem);
  99.    {Additional shortcut}
  100.    { MenuItem := TMenuItem.Create(F);
  101.     with MenuItem do
  102.     begin
  103.       ShortCut := Menus.ShortCut(VK_F11, [ssAlt]);
  104.       Name := 'RAZoomEditor2';
  105.       OnClick := Zoom.Zoom;
  106.       Visible := false;
  107.     end;
  108.     ViewsMenu.Add(MenuItem);
  109.     }
  110.   end;
  111. end;
  112.  
  113.  
  114. initialization
  115. finalization
  116.   Unregister;
  117. end.
  118.