home *** CD-ROM | disk | FTP | other *** search
- unit Crystgt;
-
- interface
-
- uses
- Crpe, Dsgnintf, Forms, Controls,
- SysUtils, WinTypes, WinProcs, Messages, Classes, TypInfo;
-
-
- type
- TOutputToList = ( ToScreen, ToPrinter );
-
- TWindowStyleList = ( MDIDefault, MDIChild);
-
- ECrystalError=Class(Exception);
-
- TCrystalGT = class(TComponent)
- private
- { Private declarations }
- FCrystalBar: Boolean;
- FReportFile, FCaptionWindow, FSelectionFormula,
- FGrpSelectFormula: string;
- FRepTop, FRepLeft, FRepWidth, FRepHeight, FPrintCopies: Integer;
- FWindowStyle: TWindowStyleList;
- FOutputTo: TOutputToList;
- protected
- procedure FSetOutputTo( Value : TOutputToList );
- procedure FSetWindowStyle( Value : TWindowStyleList );
-
- public
- { Public declarations }
- Constructor Create(AOwner:TComponent); override;
- Function Print: Integer;
- Destructor Free;
- published
- property ReportFile: string read FReportFile write FReportFile;
- property CaptionWindow: string read FCaptionWindow write FCaptionWindow;
- Property WindowTop: Integer read FRepTop write FRepTop;
- Property WindowLeft: Integer read FRepLeft write FRepLeft;
- Property WindowWidth: Integer read FRepWidth write FRepWidth;
- Property WindowHeight: Integer read FRepHeight write FRepHeight;
- Property OutputTo: TOutputToList read FOutputTo write FSetOutputTo;
- Property PrintCopies: Integer read FPrintCopies write FPrintCopies;
- Property WindowStyle: TWindowStyleList read FWindowStyle write FSetWindowStyle;
- property CrystalBar: boolean read FCrystalBar write FCrystalBar;
- property SelectionFormula: string read FSelectionFormula write FSelectionFormula;
- property GrpSelectFormula: string read FGrpSelectFormula write FGrpSelectFormula;
-
- end;
-
- Procedure Register;
-
- implementation
-
- Constructor TCrystalGT.Create(AOwner:TComponent);
- begin
- Inherited Create(AOwner);
- FCaptionWindow := 'Screen Preview';
- FRepTop := 10;
- FRepLeft := 10;
- FRepWidth := 540;
- FRepHeight := 380;
- FPrintCopies := 1;
- FCrystalBar := true;
-
- if not PEOpenEngine then
- raise ECrystalError.Create('Unable to open Crystal Engine');
- end;
-
- Destructor TCrystalGT.Free;
- begin
- PECloseEngine;
- Inherited Free;
- end;
-
- Function TCrystalGT.Print: Integer;
- var
- RepName: array[0..79] of Char;
- RepTitle: array[0..79] of Char;
- RepPrntFile: array[0..79] of Char;
- SFormula: array[0..79] of Char;
- GroupSFormula: array[0..79] of Char;
-
- JobHandle: hWnd;
- RepWin: hWnd;
- Job: Integer;
-
- begin
- Screen.Cursor := crHourglass;
-
- StrPCopy(RepTitle,FCaptionWindow);
- StrPCopy(RepName,FReportFile);
- StrPCopy(SFormula,FSelectionFormula);
-
- PEOpenEngine;
-
- Job := PEOpenPrintJob(RepName);
- JobHandle := PEGetWindowHandle(Job);
- RepWin := GetActiveWindow;
-
- PEShowPrintControls(job,FCrystalBar) ;
- PESetSelectionFormula(job,SFormula);
- PESetGroupSelectionFormula(job,GroupSFormula);
-
- if FOutPutTo = ToScreen then
- begin
- If FWindowStyle = MDIChild then
- begin
- PEOutputToWindow(Job,RepTitle,FRepTop,FRepLeft,FRepWidth,FRepHeight,
- WS_VISIBLE OR WS_CAPTION OR WS_THICKFRAME
- OR WS_SYSMENU OR WS_MINIMIZEBOX OR WS_MAXIMIZEBOX, RepWin);
- end
- else
- begin
- PEOutputToWindow(Job,RepTitle,FRepTop,FRepLeft,FRepWidth,FRepHeight,
- WS_VISIBLE OR WS_CAPTION OR WS_THICKFRAME
- OR WS_SYSMENU OR WS_MINIMIZEBOX OR WS_MAXIMIZEBOX, 0);
-
- end;
- end;
-
- if FOutPutTo = ToPrinter then
- begin
- PEOutputToPrinter(job,FPrintCopies)
- end;
-
- PEStartPrintJob(Job,True);
- PECloseEngine;
- Screen.Cursor := crDefault;
-
- end;
-
- procedure TCrystalGT.FSetOutputTo( Value : TOutputToList );
- begin
- if Value <> FOutputTo then
- begin
- FOutputTo := Value;
- end;
- end;
-
- procedure TCrystalGT.FSetWindowStyle( Value : TWindowStyleList);
- begin
- if Value <> FWindowStyle then
- begin
- FWindowStyle := Value;
-
- end;
- end;
-
-
-
- Procedure Register;
- begin
- RegisterComponents('Data Access',[TCrystalGT]);
-
- end;
-
- end.
-