home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 January / Chip_2003-01_cd1.bin / zkuste / delphi / kolekce / d567 / FLEXCEL.ZIP / Design / DFlexCelReportEditor.pas next >
Encoding:
Pascal/Delphi Source File  |  2002-09-26  |  2.0 KB  |  81 lines

  1. unit DFlexCelReportEditor;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   {$IFDEF ConditionalExpressions}{$if CompilerVersion >= 14}  //Delphi 6 or above
  8.     DesignIntf, DesignEditors,
  9.   {$IFEND}
  10.   {$ELSE}
  11.     DsgnIntf,
  12.   {$ENDIF}
  13.   UCustomFlexCelReport, UFlxMessages, UExcelEdit, UFlxDesignHelp, ShellAPI, ComObj;
  14.  
  15. type
  16.   TFlexCelReportEditor = class(TComponentEditor)
  17.   private
  18.     { Private declarations }
  19.   protected
  20.     { Protected declarations }
  21.   public
  22.     { Public declarations }
  23.     function GetVerb(Index: Integer): String; override;
  24.     function GetVerbCount: Integer; override;
  25.     procedure ExecuteVerb(Index: Integer); override;
  26.   published
  27.     { Published declarations }
  28.   end;
  29.  
  30. procedure Register;
  31.  
  32. implementation
  33. function TFlexCelReportEditor.GetVerbCount: Integer;
  34. begin
  35.   Result := 3;
  36. end;
  37.  
  38. function TFlexCelReportEditor.GetVerb(Index: Integer): String;
  39.  
  40. begin
  41.   case Index of
  42.     0: Result := 'Edit Report...';
  43.     1: Result := 'Open Report';
  44.     2: Result := 'About...';
  45.   end;
  46. end;
  47.  
  48.  
  49. procedure TFlexCelReportEditor.ExecuteVerb(Index: Integer);
  50. var
  51.   FName: string;
  52. begin
  53.   chdir(ExtractFilePath(GetActiveProjectFileName));
  54.   case Index of
  55.     0: InvokeExcelEditor((Component as TCustomFlexCelReport).DesignDataModule,(Component as TCustomFlexCelReport).Template, GetActiveProjectFileName);
  56.     1:
  57.     begin
  58.       try
  59.         FName:=SearchPathStr((Component as TCustomFlexCelReport).Template);
  60.       except
  61.         on e:Exception do
  62.         begin
  63.           ShowMessage(format(ErrNoTemplate, [e.Message, GetActiveProjectFileName]));
  64.           exit;
  65.         end;
  66.       end; //except
  67.  
  68.       ShellExecute( 0, 'open', PCHAR(FName), nil, nil, SW_SHOWMAXIMIZED);
  69.     end;
  70.  
  71.     2: ShowMessage(Format(MsgAbout,[FlexCelVersion]));
  72.   end  //case
  73. end;
  74.  
  75. procedure Register;
  76. begin
  77.   RegisterComponentEditor(TCustomFlexCelReport, TFlexCelReportEditor);
  78. end;
  79.  
  80. end.
  81.