home *** CD-ROM | disk | FTP | other *** search
- unit UReport;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- OleCtnrs, ExtCtrls, ToolWin, ComCtrls, OleCtrls, UFlDemoData,
- ActnList, Activex, UWaitCursor,
- {$IFDEF ConditionalExpressions}{$if CompilerVersion >= 14} variants,{$IFEND}{$ENDIF} //Delphi 6 or above
- {$IFDEF Excel97}Excel97, {$ELSE} Excel2000, {$ENDIF}
-
- Menus, SHDocVw;
-
- type
- TReport = class(TForm)
- Panel1: TPanel;
- ToolBar: TToolBar;
- ToolButton5: TToolButton;
- ToolBar1: TToolBar;
- ToolButton1: TToolButton;
- ActionList1: TActionList;
- ActionPrint: TAction;
- ActionPrintPreview: TAction;
- ActionZoom: TAction;
- ActionClose: TAction;
- ToolButton3: TToolButton;
- ToolButton4: TToolButton;
- ToolButton6: TToolButton;
- ToolButton7: TToolButton;
- WB: TWebBrowser;
- PopZoom: TPopupMenu;
- N501: TMenuItem;
- N1001: TMenuItem;
- N2001: TMenuItem;
- N751: TMenuItem;
- ToolButton2: TToolButton;
- procedure ActionCloseExecute(Sender: TObject);
- procedure ActionPrintPreviewExecute(Sender: TObject);
- procedure ActionPrintExecute(Sender: TObject);
- procedure N501Click(Sender: TObject);
- procedure N1001Click(Sender: TObject);
- procedure N2001Click(Sender: TObject);
- procedure ActionZoomExecute(Sender: TObject);
- procedure N751Click(Sender: TObject);
- procedure FormShow(Sender: TObject);
- private
- procedure SetZoom(const Zoom: integer);
- { Private declarations }
- public
- { Public declarations }
- end;
-
- implementation
-
- {$R *.DFM}
-
- procedure TReport.ActionCloseExecute(Sender: TObject);
- begin
- Close;
- end;
-
- procedure TReport.ActionPrintPreviewExecute(Sender: TObject);
- var
- pvain, pvaout:Olevariant;
- v: IOleCommandTarget;
- WaitCursor: IWaitCursor;
- begin
- WaitCursor:=TWaitCursor.Create;
- //Couldnt find a way to implement this for excel files...
- pvain:=null; pvaout:=null;
- v:=WB.Document as IOleCommandTarget;
- try
- if v<>nil then v.exec(nil, OLECMDID_PRINTPREVIEW, 0,pvain,pvaout);
- finally
- v._Release; //This is not automatically unreleased... dont ask why.
- end; //finally
- end;
-
- procedure TReport.ActionPrintExecute(Sender: TObject);
- var
- pvain, pvaout:Olevariant;
- v: IOleCommandTarget;
- WaitCursor: IWaitCursor;
- begin
- WaitCursor:=TWaitCursor.Create;
- pvain:=null; pvaout:=null;
- v:=WB.Document as IOleCommandTarget;
- try
- if v<>nil then v.exec(nil, OLECMDID_PRINT, 0,pvain,pvaout);
- finally
- v._Release;
- end; //finally
- end;
-
- procedure TReport.SetZoom(const Zoom: integer);
- var
- v: _Workbook;
- begin
- if not Supports(WB.Document, _Workbook, v) then exit;
- try
- if v<>nil then v.Windows[1].Zoom:=Zoom;
- finally
- v._Release;
- end; //finally
- end;
-
- procedure TReport.N501Click(Sender: TObject);
- begin
- SetZoom(50);
- end;
-
- procedure TReport.N1001Click(Sender: TObject);
- begin
- SetZoom(100)
- end;
-
- procedure TReport.N2001Click(Sender: TObject);
- begin
- SetZoom(200);
- end;
-
- procedure TReport.ActionZoomExecute(Sender: TObject);
- begin
- //Nothing
- end;
-
- procedure TReport.N751Click(Sender: TObject);
- begin
- SetZoom(75);
- end;
-
-
- procedure TReport.FormShow(Sender: TObject);
- var
- v: _workbook;
- begin
- ActionZoom.Enabled:=Supports(WB.Document, _Workbook, v);
- if v<>nil then v._Release;
- ActionZoom.Visible:=ActionZoom.Enabled;
- end;
-
- end.
-
-