2008-02-03 12:05:55 +00:00
|
|
|
{*********************************************************}
|
|
|
|
{* VPPRTPRV.PAS 1.03 *}
|
|
|
|
{*********************************************************}
|
|
|
|
|
|
|
|
{* ***** BEGIN LICENSE BLOCK ***** *}
|
|
|
|
{* Version: MPL 1.1 *}
|
|
|
|
{* *}
|
|
|
|
{* The contents of this file are subject to the Mozilla Public License *}
|
|
|
|
{* Version 1.1 (the "License"); you may not use this file except in *}
|
|
|
|
{* compliance with the License. You may obtain a copy of the License at *}
|
|
|
|
{* http://www.mozilla.org/MPL/ *}
|
|
|
|
{* *}
|
|
|
|
{* Software distributed under the License is distributed on an "AS IS" basis, *}
|
|
|
|
{* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License *}
|
|
|
|
{* for the specific language governing rights and limitations under the *}
|
|
|
|
{* License. *}
|
|
|
|
{* *}
|
|
|
|
{* The Original Code is TurboPower Visual PlanIt *}
|
|
|
|
{* *}
|
|
|
|
{* The Initial Developer of the Original Code is TurboPower Software *}
|
|
|
|
{* *}
|
|
|
|
{* Portions created by TurboPower Software Inc. are Copyright (C) 2002 *}
|
|
|
|
{* TurboPower Software Inc. All Rights Reserved. *}
|
|
|
|
{* *}
|
|
|
|
{* Contributor(s): *}
|
|
|
|
{* *}
|
|
|
|
{* ***** END LICENSE BLOCK ***** *}
|
|
|
|
|
|
|
|
{
|
|
|
|
This unit contains the visual print preview component. The display of
|
|
|
|
the print preview as well as the navigation is controlled in this component.
|
|
|
|
The PrintPreview depends on the print formats (in VpPrtFmt) to generate
|
|
|
|
the image that will be displayed to the user.
|
|
|
|
|
|
|
|
VisualPlanIt has a loose definition for starting and stopping reports.
|
|
|
|
Basically, the report ends when all the contacts, tasks and dates have
|
|
|
|
been displayed. The print formats know which of these types of elements
|
|
|
|
that it is displaying and uses that information in calculating the last
|
|
|
|
page.
|
|
|
|
|
|
|
|
It is possible to create print formats that do not have last page (the
|
|
|
|
easiest way is to create a print format with a day view and have it
|
|
|
|
increment zero days for each page). This scenario is not yet trapped
|
|
|
|
in the printing or in the print preview.
|
|
|
|
|
|
|
|
Scaling is handled simply. The size of the rectangle in which the print
|
|
|
|
format can render is changed to reflect the size.
|
|
|
|
|
|
|
|
The print preview cannot be used as an element of a print format.
|
|
|
|
}
|
|
|
|
|
|
|
|
unit VpPrtPrv;
|
|
|
|
|
|
|
|
{$I vp.inc}
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
|
|
|
{$IFDEF LCL}
|
2016-06-21 15:12:38 +00:00
|
|
|
LMessages, LCLProc, LCLType, LCLIntf,
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ELSE}
|
2016-06-21 15:12:38 +00:00
|
|
|
Windows, Messages,
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
2016-06-21 15:12:38 +00:00
|
|
|
SysUtils, Classes, Controls, Forms, Graphics, Printers,
|
|
|
|
VpBase, VpMisc, VpBaseDS, VpSR, VpException, Menus;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
type
|
2016-06-21 15:12:38 +00:00
|
|
|
TVpPageChange = procedure(Sender: TObject; NewPage: Integer) of object;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
TVpPPZoomFactor = (zfFitToControl, zfActualSize,
|
|
|
|
zf25Percent, zf33Percent, zf50Percent,
|
|
|
|
zf67Percent, zf75Percent);
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
const
|
|
|
|
ZOOM_FACTOR_VALUES: array[TVpPPZoomFactor] of Double = (
|
|
|
|
-1, 1.0, 0.25, 1.0/3, 0.5, 2.0/3, 0.75);
|
|
|
|
|
|
|
|
type
|
2008-02-03 12:05:55 +00:00
|
|
|
TVpPageInfo = record
|
2016-06-21 15:12:38 +00:00
|
|
|
Date: TDateTime;
|
|
|
|
Task: Integer;
|
|
|
|
Contact: Integer;
|
|
|
|
LastPage: Boolean;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
PVpPageInfo = ^TVpPageInfo;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
TVpPrintPreview = class(TVpCustomControl)
|
2008-02-03 12:05:55 +00:00
|
|
|
private
|
2016-06-21 15:12:38 +00:00
|
|
|
FBorderStyle: TBorderStyle;
|
|
|
|
FControlLink: TVpControlLink;
|
|
|
|
FDrawingStyle: TVpDrawingStyle;
|
|
|
|
FCurPage: Integer;
|
|
|
|
FPrinter: TPrinter;
|
|
|
|
RenderBmp: TBitmap;
|
|
|
|
WorkBmp: TBitmap;
|
|
|
|
FZoomFactor: TVpPPZoomFactor;
|
|
|
|
FBorderColor: TColor;
|
|
|
|
FOffPageColor: TColor;
|
|
|
|
FPageColor: TColor;
|
|
|
|
FPageInfo: TList;
|
|
|
|
FStartDate: TDateTime;
|
|
|
|
FEndDate: TDateTime;
|
|
|
|
FCurrentFormat: Integer;
|
|
|
|
FNeedHScroll: Boolean;
|
|
|
|
FNeedVScroll: Boolean;
|
|
|
|
FScrollX: Integer;
|
|
|
|
FScrollY: Integer;
|
|
|
|
FOnPageChange: TVpPageChange;
|
|
|
|
FDefaultPopup: TPopupMenu;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
protected
|
2016-06-21 15:12:38 +00:00
|
|
|
function CalculatePageHeight(Printer: TPrinter): Integer;
|
|
|
|
function CalculatePageWidth(Printer: TPrinter): Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure ClearPageData;
|
2016-06-21 15:12:38 +00:00
|
|
|
{$IFDEF DELPHI}
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure CMWantSpecialKey(var Msg: TCMWantSpecialKey);
|
|
|
|
message CM_WANTSPECIALKEY;
|
|
|
|
{$ENDIF}
|
|
|
|
procedure CreateParams(var Params: TCreateParams); override;
|
|
|
|
procedure CreateWnd; override;
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure DoScroll(var Msg: {$IFNDEF LCL}TWMSCROLL{$ELSE}TLMScroll{$ENDIF}; BarDirection: Integer);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure GeneratePageImage;
|
|
|
|
procedure GetLastPage;
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure InitHScrollBar(PageSize, TotalSize: Integer);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure InitializeDefaultPopup;
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure InitVScrollBar(PageSize, TotalSize: Integer);
|
|
|
|
function IsPageLoaded(PageNum: Integer): Boolean;
|
|
|
|
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure Loaded; override;
|
2016-06-21 15:12:38 +00:00
|
|
|
function LoadPage(PageNum: Integer; StartDate, EndDate: TDateTime): Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure Paint; override;
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure PopupFirstPage(Sender: TObject);
|
|
|
|
procedure PopupLastPage(Sender: TObject);
|
|
|
|
procedure PopupNextPage(Sender: TObject);
|
|
|
|
procedure PopupPrevPage(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure RemoveHScrollbar;
|
|
|
|
procedure RemoveVScrollbar;
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure SetBorderColor(const v: TColor);
|
2021-10-27 18:12:33 +00:00
|
|
|
procedure SetBorderStyle(const v: TBorderStyle); reintroduce;
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure SetControlLink(const v: TVpControlLink);
|
|
|
|
procedure SetCurPage(const v: Integer);
|
|
|
|
procedure SetDrawingStyle(const v: TVpDrawingStyle);
|
|
|
|
procedure SetEndDate(const v: TDateTime);
|
|
|
|
procedure SetOffPageColor(const v: TColor);
|
|
|
|
procedure SetPageColor(const v: TColor);
|
|
|
|
procedure SetPrinter(const v: TPrinter);
|
|
|
|
procedure SetStartDate(const v: TDateTime);
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure SetScrollBars;
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure SetZoomFactor(const v: TVpPPZoomFactor);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
// procedure VpPrintFormatChanged (var Msg : {$IFNDEF LCL}TMessage{$ELSE}TLMessage{$ENDIF}; message Vp_PrintFormatChanged;
|
2016-06-21 15:12:38 +00:00
|
|
|
{$IFDEF DELPHI}
|
|
|
|
procedure WMEraseBackground(var Msg: TWMERASEBKGND); message WM_ERASEBKGND;
|
|
|
|
procedure WMHScroll(var Msg: TWMSCROLL); message WM_HSCROLL;
|
|
|
|
procedure WMVScroll(var Msg: TWMSCROLL); message WM_VSCROLL;
|
|
|
|
procedure WMRButtonDown(var Msg: TWMRButtonDown); message WM_RBUTTONDOWN;
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ELSE}
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure WMEraseBackground(var Msg: TLMERASEBKGND); message LM_ERASEBKGND;
|
|
|
|
procedure WMHScroll(var Msg: TLMSCROLL); message LM_HSCROLL;
|
|
|
|
procedure WMVScroll(var Msg: TLMSCROLL); message LM_VSCROLL;
|
|
|
|
procedure WMRButtonDown(var Msg: TLMRButtonDown); message LM_RBUTTONDOWN;
|
2008-02-03 12:05:55 +00:00
|
|
|
{$ENDIF}
|
2016-06-21 15:12:38 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
public
|
2016-06-21 15:12:38 +00:00
|
|
|
constructor Create(AOwner: TComponent); override;
|
2008-02-03 12:05:55 +00:00
|
|
|
destructor Destroy; override;
|
|
|
|
|
|
|
|
procedure FirstPage;
|
2016-06-21 15:12:38 +00:00
|
|
|
function IsFirstPage: Boolean;
|
|
|
|
function IsLastPage: Boolean;
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure LastPage;
|
|
|
|
procedure NextPage;
|
|
|
|
procedure PrevPage;
|
|
|
|
procedure ForceUpdate;
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer); override;
|
|
|
|
|
|
|
|
property Printer: TPrinter read FPrinter write SetPrinter;
|
|
|
|
property DestPrinter: TPrinter read FPrinter write SetPrinter;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
published
|
2016-06-21 15:12:38 +00:00
|
|
|
property BorderColor: TColor read FBorderColor write SetBorderColor default clBlack;
|
|
|
|
property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle;
|
|
|
|
property ControlLink: TVpControlLink read FControlLink write SetControlLink;
|
|
|
|
property CurPage: Integer read FCurPage write SetCurPage;
|
|
|
|
// property DestPrinter: TPrinter read FPrinter write SetPrinter;
|
|
|
|
property DrawingStyle: TVpDrawingStyle read FDrawingStyle write SetDrawingStyle default ds3d;
|
|
|
|
property EndDate: TDateTime read FEndDate write SetEndDate;
|
|
|
|
property OffPageColor: TColor read FOffPageColor write SetOffPageColor default clSilver;
|
|
|
|
property PageColor: TColor read FPageColor write SetPageColor default clWhite;
|
|
|
|
property StartDate: TDateTime read FStartDate write SetStartDate;
|
|
|
|
property ZoomFactor: TVpPPZoomFactor read FZoomFactor write SetZoomFactor default zfFitToControl;
|
|
|
|
property OnPageChange: TVpPageChange read FOnPageChange write FOnPageChange;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
property Anchors;
|
|
|
|
property Align;
|
|
|
|
property Constraints;
|
|
|
|
property Cursor;
|
|
|
|
property DragCursor;
|
|
|
|
property DragMode;
|
|
|
|
property Enabled;
|
|
|
|
property HelpContext;
|
|
|
|
property Hint;
|
|
|
|
property Parent;
|
|
|
|
property ParentColor;
|
|
|
|
property ParentFont;
|
|
|
|
property ParentShowHint;
|
|
|
|
property PopupMenu;
|
|
|
|
property ShowHint;
|
|
|
|
property TabStop;
|
|
|
|
property TabOrder;
|
|
|
|
property Visible;
|
|
|
|
|
|
|
|
property OnClick;
|
|
|
|
property OnDblClick;
|
|
|
|
property OnDragDrop;
|
|
|
|
property OnDragOver;
|
|
|
|
property OnEndDrag;
|
|
|
|
property OnEnter;
|
|
|
|
property OnExit;
|
|
|
|
property OnKeyDown;
|
|
|
|
property OnKeyPress;
|
|
|
|
property OnKeyUp;
|
|
|
|
property OnMouseDown;
|
|
|
|
property OnMouseMove;
|
|
|
|
property OnMouseUp;
|
|
|
|
property OnStartDrag;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
implementation
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
constructor TVpPrintPreview.Create(AOwner: TComponent);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-06-21 15:12:38 +00:00
|
|
|
inherited Create(AOwner);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
if not (AOwner is TWinControl) then
|
2016-06-21 15:12:38 +00:00
|
|
|
raise EVpPrintPreviewError.Create(RSOwnerNotWinCtrl);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
Parent := TWinControl (AOwner);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
RenderBmp := TBitmap.Create;
|
|
|
|
WorkBmp := TBitmap.Create;
|
|
|
|
FPageInfo := TList.Create;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
FDefaultPopup := TPopupMenu.Create (Self);
|
|
|
|
InitializeDefaultPopup;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
FNeedHScroll := False;
|
|
|
|
FNeedVScroll := False;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
FCurrentFormat := -1;
|
2016-06-21 15:12:38 +00:00
|
|
|
FBorderStyle := bsSingle;
|
|
|
|
FDrawingStyle := ds3d;
|
|
|
|
FZoomFactor := zfFitToControl;
|
|
|
|
FOffPageColor := clSilver;
|
|
|
|
FPageColor := clWhite;
|
|
|
|
FBorderColor := clBlack;
|
|
|
|
FCurPage := 0;
|
|
|
|
FStartDate := Now;
|
|
|
|
FEndDate := Now + 7;
|
|
|
|
FScrollX := 0;
|
|
|
|
FScrollY := 0;
|
|
|
|
Height := 225;
|
|
|
|
Width := 169;
|
|
|
|
FPrinter := Printer;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TVpPrintPreview.Destroy;
|
|
|
|
begin
|
|
|
|
if (HandleAllocated) and Assigned (FControlLink) then
|
2016-06-21 15:12:38 +00:00
|
|
|
FControlLink.Printer.DeregisterWatcher(Handle);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
ClearPageData;
|
|
|
|
|
|
|
|
RenderBmp.Free;
|
|
|
|
WorkBmp.Free;
|
|
|
|
FPageInfo.Free;
|
|
|
|
FDefaultPopup.Free;
|
|
|
|
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
function TVpPrintPreview.CalculatePageHeight(Printer: TPrinter): Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
ScreenPPI: Integer;
|
|
|
|
PrinterPPI: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
ScreenPPI := GetDeviceCaps (Canvas.Handle, LOGPIXELSY);
|
2016-06-21 15:12:38 +00:00
|
|
|
{$IFDEF DELPHI}
|
2008-02-03 12:05:55 +00:00
|
|
|
PrinterPPI := GetDeviceCaps (Printer.Handle, LOGPIXELSY);
|
2016-06-21 15:12:38 +00:00
|
|
|
{$ELSE}
|
|
|
|
PrinterPPI := Printer.XDpi;
|
|
|
|
{$ENDIF}
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
if PrinterPPI <> 0 then
|
|
|
|
Result := Round (ScreenPPI / PrinterPPI * Printer.PageHeight)
|
|
|
|
else
|
|
|
|
Result := ScreenPPI * Printer.PageHeight;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TVpPrintPreview.CalculatePageWidth (Printer : TPrinter) : Integer;
|
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
ScreenPPI: Integer;
|
|
|
|
PrinterPPI: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
ScreenPPI := GetDeviceCaps (Canvas.Handle, LOGPIXELSX);
|
2016-06-21 15:12:38 +00:00
|
|
|
{$IFDEF DELPHI}
|
2008-02-03 12:05:55 +00:00
|
|
|
PrinterPPI := GetDeviceCaps (Printer.Handle, LOGPIXELSX);
|
2016-06-21 15:12:38 +00:00
|
|
|
{$ELSE}
|
|
|
|
PrinterPPI := Printer.XDpi;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
if PrinterPPI <> 0 then
|
|
|
|
Result := Round (ScreenPPI / PrinterPPI * Printer.PageWidth)
|
|
|
|
else
|
|
|
|
Result := ScreenPPI * Printer.PageHeight;
|
|
|
|
{$ENDIF}
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.ClearPageData;
|
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
i: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
for i := FPageInfo.Count - 1 downto 0 do begin
|
|
|
|
if Assigned (FPageInfo[i]) then
|
|
|
|
FreeMem (FPageInfo[i]);
|
|
|
|
FPageInfo.Delete (i);
|
|
|
|
end;
|
|
|
|
CurPage := 0;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
{$IFDEF DELPHI}
|
2008-02-03 12:05:55 +00:00
|
|
|
procedure TVpPrintPreview.CMWantSpecialKey(var Msg: TCMWantSpecialKey);
|
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
Msg.Result := 1;
|
|
|
|
end;
|
|
|
|
{$ENDIF}
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.CreateParams(var Params: TCreateParams);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
inherited CreateParams (Params);
|
|
|
|
|
|
|
|
with Params do begin
|
|
|
|
Style := Style or WS_TABSTOP;
|
|
|
|
if FNeedHScroll then
|
2016-07-15 23:25:07 +00:00
|
|
|
Style := Style or WS_HSCROLL;
|
2008-02-03 12:05:55 +00:00
|
|
|
if FNeedVScroll then
|
2016-07-15 23:25:07 +00:00
|
|
|
Style := Style or WS_VSCROLL;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.CreateWnd;
|
|
|
|
begin
|
2016-06-21 15:12:38 +00:00
|
|
|
if HandleAllocated and Assigned(FControlLink) then
|
|
|
|
FControlLink.Printer.DeregisterWatcher(Handle);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
inherited CreateWnd;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
if Assigned(FControlLink) then
|
|
|
|
FControlLink.Printer.RegisterWatcher(Handle);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.DoScroll(var Msg: {$IFNDEF LCL}TWMSCROLL{$ELSE}TLMScroll{$ENDIF};
|
|
|
|
BarDirection: Integer);
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
ScrollBarInfo: TScrollInfo;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
Msg.Result := 0;
|
2016-06-21 15:12:38 +00:00
|
|
|
ScrollBarInfo.cbSize := SizeOf(TScrollInfo);
|
2008-02-03 12:05:55 +00:00
|
|
|
ScrollBarInfo.fMask := SIF_ALL;
|
|
|
|
GetScrollInfo (Handle, BarDirection, ScrollBarInfo);
|
|
|
|
ScrollBarInfo.fMask := SIF_POS;
|
|
|
|
case Msg.ScrollCode of
|
|
|
|
SB_TOP : ScrollBarInfo.nPos := ScrollBarInfo.nMin;
|
|
|
|
SB_BOTTOM : ScrollBarInfo.nPos := ScrollBarInfo.nMax;
|
2016-06-21 15:12:38 +00:00
|
|
|
SB_LINEUP : Dec(ScrollBarInfo.nPos, 1);
|
|
|
|
SB_LINEDOWN : Inc(ScrollBarInfo.nPos, 1);
|
|
|
|
SB_PAGEUP : Dec(ScrollBarInfo.nPos, ScrollBarInfo.nPage );
|
|
|
|
SB_PAGEDOWN : Inc(ScrollBarInfo.nPos, ScrollBarInfo.nPage);
|
2008-02-03 12:05:55 +00:00
|
|
|
SB_THUMBTRACK,
|
|
|
|
SB_THUMBPOSITION : ScrollBarInfo.nPos := Msg.Pos;
|
|
|
|
SB_ENDSCROLL : Exit;
|
|
|
|
end;
|
|
|
|
|
|
|
|
ScrollBarInfo.fMask := SIF_POS;
|
2016-06-21 15:12:38 +00:00
|
|
|
if ScrollBarInfo.nPos < ScrollBarInfo.nMin then
|
2008-02-03 12:05:55 +00:00
|
|
|
ScrollBarInfo.nPos := ScrollBarInfo.nMin;
|
2016-06-21 15:12:38 +00:00
|
|
|
if ScrollBarInfo.nPos + Integer(ScrollBarInfo.nPage) >
|
2008-02-03 12:05:55 +00:00
|
|
|
ScrollBarInfo.nMax Then
|
|
|
|
ScrollBarInfo.nPos := ScrollBarInfo.nMax - Integer (ScrollBarInfo.nPage);
|
|
|
|
|
|
|
|
case BarDirection of
|
|
|
|
SB_HORZ : FScrollX := ScrollBarInfo.nPos;
|
|
|
|
SB_VERT : FScrollY := ScrollBarInfo.nPos;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
SetScrollInfo(Handle, BarDirection, ScrollBarInfo, True);
|
2008-02-03 12:05:55 +00:00
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.FirstPage;
|
|
|
|
begin
|
|
|
|
CurPage := 0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.ForceUpdate;
|
|
|
|
begin
|
|
|
|
if not Assigned (FControlLink) then
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
if not Assigned (FControlLink.Printer) then
|
|
|
|
Exit;
|
|
|
|
|
2016-07-03 15:42:06 +00:00
|
|
|
ClearPageData;
|
|
|
|
GeneratePageImage;
|
|
|
|
Invalidate;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.GeneratePageImage;
|
|
|
|
var
|
2016-11-21 17:12:05 +00:00
|
|
|
LastPage: Boolean = false;
|
2016-06-21 15:12:38 +00:00
|
|
|
UseDate: TDateTime;
|
|
|
|
UseContact: Integer;
|
|
|
|
UseTask: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-06-21 15:12:38 +00:00
|
|
|
if not Assigned(FControlLink) then
|
2008-02-03 12:05:55 +00:00
|
|
|
Exit;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
if not Assigned(FControlLink.Printer) then
|
2008-02-03 12:05:55 +00:00
|
|
|
Exit;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
if (FControlLink.Printer.PrintFormats.Count = 0) or
|
|
|
|
(FControlLink.Printer.CurFormat < 0)
|
|
|
|
then
|
2008-02-03 12:05:55 +00:00
|
|
|
Exit;
|
|
|
|
|
|
|
|
FCurrentFormat := FControlLink.Printer.CurFormat;
|
|
|
|
|
|
|
|
if (FPrinter <> nil) and
|
2016-06-21 15:12:38 +00:00
|
|
|
((RenderBmp.Width = 0) or (RenderBmp.Height = 0)) then
|
|
|
|
begin
|
|
|
|
RenderBmp.Width := CalculatePageWidth(FPrinter);
|
|
|
|
RenderBmp.Height := CalculatePageHeight(FPrinter);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if (FPrinter = nil) and
|
|
|
|
((RenderBmp.Width = 0) or (RenderBmp.Height = 0)) then
|
|
|
|
begin
|
2008-02-03 12:05:55 +00:00
|
|
|
RenderBmp.Width := ClientWidth;
|
|
|
|
RenderBmp.Height := ClientHeight;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
if not IsPageLoaded(CurPage) then
|
|
|
|
LoadPage(CurPage, FStartDate, FEndDate);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
RenderBmp.Canvas.Brush.Color := FPageColor;
|
2016-07-08 10:43:54 +00:00
|
|
|
RenderBmp.Canvas.Brush.Style := bsSolid;
|
2008-02-03 12:05:55 +00:00
|
|
|
RenderBmp.Canvas.Pen.Color := FBorderColor;
|
2016-07-08 10:43:54 +00:00
|
|
|
RenderBmp.Canvas.Pen.Style := psSolid;
|
2016-06-21 15:12:38 +00:00
|
|
|
RenderBmp.Canvas.FillRect(Rect(0, 0, RenderBmp.Width, RenderBmp.Height));
|
|
|
|
|
|
|
|
if not IsPageLoaded(CurPage) then
|
|
|
|
FControlLink.Printer.PaintToCanvasRect(
|
|
|
|
RenderBmp.Canvas,
|
|
|
|
Rect(0, 0, RenderBmp.Width, RenderBmp.Height),
|
|
|
|
StartDate
|
|
|
|
)
|
2008-02-03 12:05:55 +00:00
|
|
|
else begin
|
2016-06-21 15:12:38 +00:00
|
|
|
UseDate := PVpPageInfo(FPageInfo[CurPage]).Date;
|
|
|
|
UseContact := PVpPageInfo(FPageInfo[CurPage]).Contact;
|
|
|
|
UseTask := PVpPageInfo(FPageInfo[CurPage]).Task;
|
|
|
|
FControlLink.Printer.RenderPage(
|
|
|
|
RenderBmp.Canvas,
|
|
|
|
Rect(0, 0, RenderBmp.Width, RenderBmp.Height),
|
|
|
|
CurPage,
|
|
|
|
UseDate,
|
|
|
|
EndDate,
|
|
|
|
UseContact,
|
|
|
|
UseTask,
|
|
|
|
LastPage
|
|
|
|
);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
SetScrollBars;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.GetLastPage;
|
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
i: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
i := FPageInfo.Count - 1;
|
2016-06-21 15:12:38 +00:00
|
|
|
while (not PVpPageInfo(FPageInfo[i]).LastPage) and (i < FPageInfo.Count) do
|
|
|
|
begin
|
|
|
|
inc(i);
|
|
|
|
LoadPage(i, StartDate, EndDate);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.InitHScrollBar(PageSize, TotalSize: Integer);
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
ScrollBarInfo: TScrollInfo;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
FNeedHScroll := True;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
ScrollBarInfo.cbSize := SizeOf (TScrollInfo);
|
|
|
|
ScrollBarInfo.fMask := SIF_ALL or SIF_DISABLENOSCROLL;
|
|
|
|
ScrollBarInfo.nMin := 0;
|
|
|
|
ScrollBarInfo.nMax := TotalSize;
|
|
|
|
ScrollBarInfo.nPage := PageSize;
|
|
|
|
ScrollBarInfo.nPos := 0;
|
2008-02-03 12:05:55 +00:00
|
|
|
ScrollBarInfo.nTrackPos := 0;
|
2016-06-21 15:12:38 +00:00
|
|
|
|
|
|
|
SetScrollInfo(Handle, SB_HORZ, ScrollBarInfo, True);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.InitializeDefaultPopup;
|
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
NewItem: TMenuItem;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if RSPrintPrvPrevPage <> '' then begin
|
|
|
|
NewItem := TMenuItem.Create (Self);
|
|
|
|
NewItem.Caption := RSPrintPrvPrevPage;
|
|
|
|
NewItem.OnClick := PopupPrevPage;
|
|
|
|
NewItem.Tag := 1;
|
2016-06-21 15:12:38 +00:00
|
|
|
FDefaultPopup.Items.Add(NewItem);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
if RSPrintPrvNextPage <> '' then begin
|
|
|
|
NewItem := TMenuItem.Create (Self);
|
|
|
|
NewItem.Caption := RSPrintPrvNextPage;
|
|
|
|
NewItem.OnClick := PopupNextPage;
|
|
|
|
NewItem.Tag := 2;
|
2016-06-21 15:12:38 +00:00
|
|
|
FDefaultPopup.Items.Add(NewItem);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
if RSPrintPrvFirstPage <> '' then begin
|
|
|
|
NewItem := TMenuItem.Create (Self);
|
|
|
|
NewItem.Caption := RSPrintPrvFirstPage;
|
|
|
|
NewItem.OnClick := PopupFirstPage;
|
|
|
|
NewItem.Tag := 1;
|
2016-06-21 15:12:38 +00:00
|
|
|
FDefaultPopup.Items.Add(NewItem);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
if RSPrintPrvLastPage <> '' then begin
|
|
|
|
NewItem := TMenuItem.Create (Self);
|
|
|
|
NewItem.Caption := RSPrintPrvLastPage;
|
|
|
|
NewItem.OnClick := PopupLastPage;
|
|
|
|
NewItem.Tag := 2;
|
2016-06-21 15:12:38 +00:00
|
|
|
FDefaultPopup.Items.Add(NewItem);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.InitVScrollBar(PageSize, TotalSize: Integer);
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
ScrollBarInfo: TScrollInfo;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
FNeedVScroll := True;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
ScrollBarInfo.cbSize := SizeOf (TScrollInfo);
|
|
|
|
ScrollBarInfo.fMask := SIF_ALL or SIF_DISABLENOSCROLL;
|
|
|
|
ScrollBarInfo.nMin := 0;
|
|
|
|
ScrollBarInfo.nMax := TotalSize;
|
|
|
|
ScrollBarInfo.nPage := PageSize;
|
|
|
|
ScrollBarInfo.nTrackPos := 0;
|
|
|
|
ScrollBarInfo.nPos := 0;
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
SetScrollInfo (Handle, SB_VERT, ScrollBarInfo, True);
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
function TVpPrintPreview.IsFirstPage: Boolean;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
Result := CurPage = 0;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
function TVpPrintPreview.IsLastPage: Boolean;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if FPageInfo.Count = 0 then
|
|
|
|
Result := True
|
2016-06-21 15:12:38 +00:00
|
|
|
else
|
|
|
|
if CurPage < FPageInfo.Count then
|
|
|
|
Result := PVpPageInfo(FPageInfo[CurPage]).LastPage
|
2008-02-03 12:05:55 +00:00
|
|
|
else begin
|
|
|
|
GetLastPage;
|
2016-06-21 15:12:38 +00:00
|
|
|
Result := PVpPageInfo(FPageInfo[CurPage]).LastPage;
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
function TVpPrintPreview.IsPageLoaded(PageNum: Integer): Boolean;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
Result := PageNum < FPageInfo.Count;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.KeyDown(var Key: Word; Shift: TShiftState);
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
PopupPoint: TPoint;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
case Key of
|
2016-06-21 15:12:38 +00:00
|
|
|
VK_LEFT, VK_PRIOR :
|
2008-02-03 12:05:55 +00:00
|
|
|
if ssCtrl in Shift then
|
|
|
|
FirstPage
|
|
|
|
else
|
|
|
|
PrevPage;
|
2016-06-21 15:12:38 +00:00
|
|
|
|
|
|
|
VK_RIGHT, VK_NEXT:
|
2008-02-03 12:05:55 +00:00
|
|
|
if ssCtrl in Shift then
|
|
|
|
LastPage
|
|
|
|
else
|
|
|
|
NextPage;
|
2016-06-21 15:12:38 +00:00
|
|
|
|
|
|
|
$5A: {z}
|
2008-02-03 12:05:55 +00:00
|
|
|
if ssCtrl in Shift then begin
|
2016-06-21 15:12:38 +00:00
|
|
|
if ZoomFactor = High(FZoomFactor) then
|
|
|
|
ZOomFactor := Low(FZoomFactor)
|
2008-02-03 12:05:55 +00:00
|
|
|
else
|
2016-06-21 15:12:38 +00:00
|
|
|
ZoomFactor := Succ(FZoomFactor);
|
|
|
|
end else
|
|
|
|
if ssShift in Shift then begin
|
|
|
|
if ZoomFactor = Low(FZoomFactor) then
|
|
|
|
ZOomFactor := High(FZoomFactor)
|
2008-02-03 12:05:55 +00:00
|
|
|
else
|
2016-06-21 15:12:38 +00:00
|
|
|
ZoomFactor := Pred(FZoomFactor);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2016-06-21 15:12:38 +00:00
|
|
|
$46: {f}
|
|
|
|
if (ssCtrl in Shift) and Assigned(ControlLink) then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
if ControlLink.Printer.CurFormat < ControlLink.Printer.PrintFormats.Count - 1 then
|
|
|
|
ControlLink.Printer.CurFormat := ControlLink.Printer.CurFormat + 1
|
|
|
|
else
|
|
|
|
ControlLink.Printer.CurFormat := 0;
|
2016-06-21 15:12:38 +00:00
|
|
|
end else
|
|
|
|
if (ssShift in Shift) and Assigned(ControlLink) then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
if ControlLink.Printer.CurFormat > 0 then
|
|
|
|
ControlLink.Printer.CurFormat := ControlLink.Printer.CurFormat - 1
|
|
|
|
else
|
|
|
|
ControlLink.Printer.CurFormat := ControlLink.Printer.PrintFormats.Count - 1;
|
|
|
|
end;
|
2016-06-21 15:12:38 +00:00
|
|
|
{$IFDEF DELPHI}
|
|
|
|
VK_TAB:
|
2008-02-03 12:05:55 +00:00
|
|
|
if ssShift in Shift then
|
2016-06-21 15:12:38 +00:00
|
|
|
Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, False))
|
2008-02-03 12:05:55 +00:00
|
|
|
else
|
2016-06-21 15:12:38 +00:00
|
|
|
Windows.SetFocus(GetNextDlgTabItem(GetParent(Handle), Handle, True));
|
|
|
|
{$ENDIF}
|
|
|
|
VK_F10:
|
|
|
|
if (ssShift in Shift) and not Assigned(PopupMenu) then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
PopupPoint := GetClientOrigin;
|
2016-06-21 15:12:38 +00:00
|
|
|
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
2016-06-21 15:12:38 +00:00
|
|
|
VK_APPS:
|
2008-02-03 12:05:55 +00:00
|
|
|
if not Assigned (PopupMenu) then begin
|
|
|
|
PopupPoint := GetClientOrigin;
|
2016-06-21 15:12:38 +00:00
|
|
|
FDefaultPopup.Popup(PopupPoint.x + 10, PopupPoint.y + 10);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
else
|
|
|
|
inherited;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.LastPage;
|
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
i: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if CurPage < FPageInfo.Count then begin
|
|
|
|
i := CurPage;
|
2016-06-21 15:12:38 +00:00
|
|
|
if (not PVpPageInfo(FPageInfo[i]).LastPage) and (i < FPageInfo.Count) then
|
|
|
|
inc(i);
|
|
|
|
if (not PVpPageInfo(FPageInfo[i]).LastPage) then
|
2008-02-03 12:05:55 +00:00
|
|
|
GetLastPage;
|
|
|
|
end else
|
|
|
|
GetLastPage;
|
|
|
|
CurPage := FPageInfo.Count - 1;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.Loaded;
|
|
|
|
begin
|
|
|
|
inherited Loaded;
|
|
|
|
DestPrinter := Printer;
|
|
|
|
GeneratePageImage;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ Loads the requested page. Returns the last page loaded. If the
|
|
|
|
return value is less than the requested page, the requested page
|
|
|
|
is past the last page }
|
2016-06-21 15:12:38 +00:00
|
|
|
function TVpPrintPreview.LoadPage(PageNum: Integer;
|
|
|
|
StartDate, EndDate: TDateTime): Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
i: Integer;
|
|
|
|
LastPage: Boolean;
|
|
|
|
PPageInfo: PVpPageInfo;
|
|
|
|
ADate: TDateTime;
|
|
|
|
ATask: Integer;
|
|
|
|
AContact: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-11-21 17:12:05 +00:00
|
|
|
Unused(EndDate);
|
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
Result := PageNum;
|
|
|
|
if PageNum < FPageInfo.Count then
|
|
|
|
Exit;
|
|
|
|
|
2016-07-04 19:00:42 +00:00
|
|
|
if not Assigned(FControlLink) then
|
2008-02-03 12:05:55 +00:00
|
|
|
Exit;
|
|
|
|
|
2016-07-04 19:00:42 +00:00
|
|
|
if not Assigned(FControlLink.Printer) then
|
2008-02-03 12:05:55 +00:00
|
|
|
Exit;
|
|
|
|
|
|
|
|
i := FPageInfo.Count - 1;
|
|
|
|
LastPage := False;
|
|
|
|
|
|
|
|
if FPageInfo.Count = 0 then begin
|
2016-07-04 19:00:42 +00:00
|
|
|
GetMem(PPageInfo, SizeOf(TVpPageInfo));
|
2008-02-03 12:05:55 +00:00
|
|
|
PPageInfo.Date := StartDate;
|
|
|
|
PPageInfo.Contact := 0;
|
|
|
|
PPageInfo.Task := 0;
|
|
|
|
PPageInfo.LastPage := False;
|
2016-07-04 15:53:06 +00:00
|
|
|
FPageInfo.Add(PPageInfo);
|
2008-02-03 12:05:55 +00:00
|
|
|
i := 0;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
PPageInfo := PVpPageInfo(FPageInfo[i]);
|
|
|
|
ADate := PPageInfo.Date;
|
2008-02-03 12:05:55 +00:00
|
|
|
AContact := PPageInfo.Contact;
|
2016-06-21 15:12:38 +00:00
|
|
|
ATask := PPageInfo.Task;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
{ The only way to see how the pages are going to increment is to render
|
|
|
|
them and get the return information }
|
|
|
|
while (i <= PageNum) and (not LastPage) do begin
|
2016-06-21 15:12:38 +00:00
|
|
|
FControlLink.Printer.RenderPage(
|
|
|
|
RenderBmp.Canvas,
|
|
|
|
Rect(0, 0, RenderBmp.Width, RenderBmp.Height),
|
|
|
|
i + 1,
|
|
|
|
ADate,
|
|
|
|
FEndDate,
|
|
|
|
AContact,
|
|
|
|
ATask,
|
|
|
|
LastPage
|
|
|
|
);
|
2008-02-03 12:05:55 +00:00
|
|
|
Result := i;
|
2016-06-21 15:12:38 +00:00
|
|
|
GetMem(PPageInfo, SizeOf(TVpPageInfo));
|
|
|
|
PPageInfo.Date := ADate;
|
|
|
|
PPageInfo.Task := ATask;
|
|
|
|
PPageInfo.Contact := AContact;
|
2008-02-03 12:05:55 +00:00
|
|
|
PPageInfo.LastPage := LastPage;
|
2016-06-21 15:12:38 +00:00
|
|
|
FPageInfo.Add(PPageInfo);
|
|
|
|
inc(i);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.NextPage;
|
|
|
|
begin
|
|
|
|
if CurPage < FPageInfo.Count then begin
|
2016-06-21 15:12:38 +00:00
|
|
|
if not PVpPageInfo(FPageInfo[CurPage]).LastPage then
|
2008-02-03 12:05:55 +00:00
|
|
|
CurPage := CurPage + 1;
|
|
|
|
end else
|
|
|
|
CurPage := CurPage + 1;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.Paint;
|
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
RealWidth: Integer;
|
|
|
|
RealHeight: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
procedure Clear;
|
|
|
|
begin
|
|
|
|
if RenderBmp.Width > ClientWidth then
|
|
|
|
WorkBmp.Width := RenderBmp.Width
|
|
|
|
else
|
|
|
|
WorkBmp.Width := ClientWidth;
|
|
|
|
if RenderBmp.Height > ClientHeight then
|
|
|
|
WorkBmp.Height := RenderBmp.Height
|
|
|
|
else
|
|
|
|
WorkBmp.Height := ClientHeight;
|
|
|
|
RealWidth := ClientWidth;
|
|
|
|
RealHeight := ClientHeight;
|
|
|
|
|
2016-07-08 10:43:54 +00:00
|
|
|
WorkBmp.Canvas.Brush.Style := bsSolid;
|
2008-02-03 12:05:55 +00:00
|
|
|
WorkBmp.Canvas.Brush.Color := FOffPageColor;
|
|
|
|
WorkBmp.Canvas.Brush.Color := FPageColor;
|
|
|
|
WorkBmp.Canvas.Pen.Color := FBorderColor;
|
2016-07-08 10:43:54 +00:00
|
|
|
WorkBmp.Canvas.Pen.Style := psSolid;
|
|
|
|
|
|
|
|
WorkBmp.Canvas.FillRect(ClientRect);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure DrawBorders;
|
2016-07-06 21:49:00 +00:00
|
|
|
var
|
|
|
|
R: TRect;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if FBorderStyle = bsSingle then begin
|
2016-07-06 21:49:00 +00:00
|
|
|
R := ClientRect;
|
2008-02-03 12:05:55 +00:00
|
|
|
if FDrawingStyle = dsFlat then begin
|
2016-07-06 21:49:00 +00:00
|
|
|
// Draw a simple rectangular border
|
|
|
|
//InflateRect(R, 1, 1);
|
|
|
|
DrawBevelRect(WorkBmp.Canvas, R, clBtnShadow, clBtnShadow);
|
|
|
|
{
|
|
|
|
DrawBevelRect(WorkBmp.Canvas, R, clBtnShadow, clBtnHighlight);
|
|
|
|
InflateRect(R, 1,1);
|
|
|
|
DrawBevelRect(WorkBmp.Canvas, R, clBtnHighlight, clBtnShadow);
|
|
|
|
}
|
2016-06-21 15:12:38 +00:00
|
|
|
end else
|
|
|
|
if FDrawingStyle = ds3d then begin
|
2016-07-06 21:49:00 +00:00
|
|
|
// Draw a 3d bevel
|
|
|
|
dec(R.Right);
|
|
|
|
dec(R.Bottom);
|
|
|
|
DrawBevelRect(WorkBmp.Canvas, R, clBtnShadow, clBtnHighlight);
|
|
|
|
InflateRect(R, -1, -1);
|
|
|
|
DrawBevelRect(WorkBmp.Canvas, R, cl3DDkShadow, clBtnFace);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure AddPageBorder;
|
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
w: Integer;
|
|
|
|
h: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if RealWidth > ClientWidth - 2 then
|
|
|
|
w := ClientWidth - 2
|
|
|
|
else
|
|
|
|
w := RealWidth;
|
|
|
|
if RealHeight > ClientHeight - 2 then
|
|
|
|
h := ClientHeight - 2
|
|
|
|
else
|
|
|
|
h := RealHeight;
|
|
|
|
WorkBmp.Canvas.Pen.Color := FBorderColor;
|
2016-06-21 15:12:38 +00:00
|
|
|
WorkBmp.Canvas.MoveTo(2, 2);
|
|
|
|
WorkBmp.Canvas.LineTo(2, h);
|
|
|
|
WorkBmp.Canvas.MoveTo(2, 2);
|
|
|
|
WorkBmp.Canvas.LineTo(w, 2);
|
2008-02-03 12:05:55 +00:00
|
|
|
|
|
|
|
if (RealWidth < ClientWidth - 2) then begin
|
2016-06-21 15:12:38 +00:00
|
|
|
WorkBmp.Canvas.MoveTo(RealWidth, 2);
|
|
|
|
WorkBmp.Canvas.LineTo(RealWidth, h + 1);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
if (RealHeight < ClientHeight - 2) then begin
|
2016-06-21 15:12:38 +00:00
|
|
|
WorkBmp.Canvas.MoveTo(2, RealHeight);
|
|
|
|
WorkBmp.Canvas.LineTo(w + 1, RealHeight);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
function GetAspectRectangle: TRect;
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
ScaleX: Extended;
|
|
|
|
ScaleY: Extended;
|
|
|
|
Offset1: Integer;
|
|
|
|
Offset2: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
Offset1 := 3;
|
|
|
|
Offset2 := 3;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
if Assigned(FPrinter) then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
if ClientWidth - (Offset1 + Offset2) <> 0 then
|
|
|
|
ScaleX := FPrinter.PageWidth / (ClientWidth - (Offset1 + Offset2))
|
|
|
|
else
|
|
|
|
ScaleX := 1;
|
|
|
|
if ClientHeight - (Offset1 + Offset2) <> 0 then
|
|
|
|
ScaleY := FPrinter.PageHeight / (ClientHeight - (Offset1 + Offset2))
|
|
|
|
else
|
|
|
|
ScaleY := 1;
|
2016-07-03 20:30:06 +00:00
|
|
|
Result.TopLeft := Point(Offset1, Offset1);
|
|
|
|
if ScaleX > ScaleY then
|
|
|
|
Result.BottomRight := Point(ClientWidth - Offset2, round(FPrinter.PageHeight / ScaleX))
|
|
|
|
else
|
|
|
|
Result.BottomRight := Point(Round(FPrinter.PageWidth / ScaleY), ClientHeight - Offset2);
|
2008-02-03 12:05:55 +00:00
|
|
|
end else
|
2016-06-21 15:12:38 +00:00
|
|
|
Result := Rect(3, 3, ClientWidth, ClientHeight);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure DrawPreview;
|
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
AspectRect: TRect;
|
|
|
|
WorkHeight: Integer;
|
|
|
|
WorkWidth: Integer;
|
2016-07-03 20:30:06 +00:00
|
|
|
srcRect, dstRect: TRect;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if FControlLink.Printer.PrintFormats.Count <= 0 then
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
if CurPage > FPageInfo.Count then
|
|
|
|
GeneratePageImage;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
if FZoomFactor = zfFitToControl then
|
|
|
|
begin
|
|
|
|
AspectRect := GetAspectRectangle;
|
2016-07-03 20:30:06 +00:00
|
|
|
srcRect := Rect(0, 0, RenderBmp.Width, RenderBmp.Height);
|
|
|
|
WorkBmp.Canvas.CopyRect(AspectRect, RenderBmp.Canvas, srcRect);
|
2016-06-21 15:12:38 +00:00
|
|
|
RealWidth := AspectRect.Right - AspectRect.Left + 3;
|
|
|
|
RealHeight := AspectRect.Bottom - AspectRect.Top + 3;
|
2016-07-03 20:30:06 +00:00
|
|
|
end else
|
|
|
|
begin
|
|
|
|
WorkWidth := Round(RenderBmp.Width * ZOOM_FACTOR_VALUES[FZoomFactor]);
|
|
|
|
WorkHeight := Round(RenderBmp.Height * ZOOM_FACTOR_VALUES[FZoomFactor]);
|
|
|
|
if WorkHeight > ClientHeight - 3 then
|
|
|
|
WorkHeight := ClientHeight - 3;
|
|
|
|
if WorkWidth > ClientWidth - 3 then
|
|
|
|
WorkWidth := ClientWidth - 3;
|
|
|
|
srcRect := Rect(
|
|
|
|
Round(FScrollX / ZOOM_FACTOR_VALUES[FZoomFactor]),
|
|
|
|
Round(FScrollY / ZOOM_FACTOR_VALUES[FZoomFactor]),
|
|
|
|
Round((WorkWidth + FScrollX) / ZOOM_FACTOR_VALUES[FZoomFactor]),
|
|
|
|
Round((WorkHeight + FScrollY) / ZOOM_FACTOR_VALUES[FZoomFactor])
|
|
|
|
);
|
|
|
|
dstRect := Rect(3, 3, WorkWidth, WorkHeight);
|
|
|
|
WorkBmp.Canvas.CopyRect(dstRect, RenderBmp.Canvas, srcRect);
|
|
|
|
RealWidth := round(RenderBmp.Width / ZOOM_FACTOR_VALUES[FZoomFactor]);
|
|
|
|
RealHeight := round(RenderBmp.Height / ZOOM_FACTOR_VALUES[FZoomFactor]);
|
|
|
|
end;
|
2016-06-21 15:12:38 +00:00
|
|
|
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure RenderImage;
|
|
|
|
begin
|
2016-07-03 20:30:06 +00:00
|
|
|
Canvas.CopyRect(ClientRect, WorkBmp.Canvas, ClientRect);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
Clear;
|
|
|
|
DrawBorders;
|
|
|
|
if FControlLink = nil then
|
|
|
|
Exit;
|
|
|
|
DrawPreview;
|
|
|
|
AddPageBorder;
|
|
|
|
finally
|
|
|
|
RenderImage;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.PrevPage;
|
|
|
|
begin
|
|
|
|
if FCurPage > 0 then
|
|
|
|
CurPage := CurPage - 1;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.PopupFirstPage(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
FirstPage;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.PopupLastPage(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
LastPage;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.PopupNextPage(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
NextPage;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.PopupPrevPage(Sender: TObject);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
PrevPage;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.RemoveHScrollbar;
|
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
Style: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
FNeedHScroll := False;
|
2016-06-21 15:12:38 +00:00
|
|
|
Style := GetWindowLong(Handle, GWL_STYLE);
|
2008-02-03 12:05:55 +00:00
|
|
|
if ((Style and WS_HSCROLL) <> 0) then begin
|
2016-06-21 15:12:38 +00:00
|
|
|
SetWindowLong(Handle, GWL_STYLE, Style and not WS_HSCROLL);
|
2008-02-03 12:05:55 +00:00
|
|
|
RecreateWnd{$IFDEF LCL}(Self){$ENDIF};
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.RemoveVScrollbar;
|
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
Style: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
FNeedVScroll := False;
|
|
|
|
Style := GetWindowLong (Handle, GWL_STYLE);
|
|
|
|
if ((Style and WS_VSCROLL) <> 0) then begin
|
|
|
|
SetWindowLong (Handle, GWL_STYLE, Style and not WS_VSCROLL);
|
|
|
|
RecreateWnd{$IFDEF LCL}(Self){$ENDIF};
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.SetBorderColor(const v: TColor);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if v <> FBorderColor then begin
|
|
|
|
FBorderColor := v;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.SetBorderStyle(const v: TBorderStyle);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if v <> FBorderStyle then begin
|
|
|
|
FBorderStyle := v;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-06-21 15:12:38 +00:00
|
|
|
inherited SetBounds(ALeft, ATop, AWidth, AHeight);
|
2008-02-03 12:05:55 +00:00
|
|
|
SetScrollBars;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.SetControlLink(const v: TVpControlLink);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if FControlLink <> v then begin
|
|
|
|
if Assigned (FControlLink) then
|
2016-06-21 15:12:38 +00:00
|
|
|
FControlLink.Printer.DeregisterWatcher(Handle);
|
2008-02-03 12:05:55 +00:00
|
|
|
FControlLink := v;
|
2016-06-21 15:12:38 +00:00
|
|
|
if Assigned(FControlLink) then
|
|
|
|
FControlLink.Printer.RegisterWatcher(Handle);
|
2008-02-03 12:05:55 +00:00
|
|
|
ClearPageData;
|
|
|
|
GeneratePageImage;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.SetCurPage(const v: Integer);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if (v >= 0) and (v <> FCurPage) then begin
|
|
|
|
FCurPage := v;
|
|
|
|
if not (csDestroying in ComponentState) then begin
|
|
|
|
GeneratePageImage;
|
|
|
|
Invalidate;
|
2016-06-21 15:12:38 +00:00
|
|
|
if Assigned(FOnPageChange) then
|
|
|
|
FOnPageChange(Self, FCurPage);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.SetDrawingStyle(const v: TVpDrawingStyle);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if v <> FDrawingStyle then begin
|
|
|
|
FDrawingStyle := v;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.SetEndDate(const v: TDateTime);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if v <> FEndDate then begin
|
|
|
|
FEndDate := v;
|
|
|
|
ClearPageData;
|
|
|
|
GeneratePageImage;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.SetOffPageColor(const v: TColor);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if v <> FOffPageColor then begin
|
|
|
|
FOffPageColor := v;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.SetPageColor(const v: TColor);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if v <> FPageColor then begin
|
|
|
|
FPageColor := v;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.SetPrinter(const v: TPrinter);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if FPrinter <> v then begin
|
|
|
|
FPrinter := v;
|
2016-06-21 15:12:38 +00:00
|
|
|
RenderBmp.Width := CalculatePageWidth(v);
|
|
|
|
RenderBmp.Height := CalculatePageHeight(v);
|
2008-02-03 12:05:55 +00:00
|
|
|
ClearPageData;
|
|
|
|
GeneratePageImage;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TVpPrintPreview.SetScrollBars;
|
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
RealWidth: Integer;
|
|
|
|
RealHeight: Integer;
|
2016-07-16 10:44:10 +00:00
|
|
|
Style: DWord;
|
2016-06-21 15:12:38 +00:00
|
|
|
NeedRecreate: Boolean;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if csDesigning in ComponentState then
|
|
|
|
Exit;
|
|
|
|
|
|
|
|
FScrollX := 0;
|
|
|
|
FScrollY := 0;
|
|
|
|
RealHeight := ClientHeight;
|
2016-06-21 15:12:38 +00:00
|
|
|
RealWidth := ClientWidth;
|
|
|
|
if ZoomFactor = zfFitToControl then begin
|
|
|
|
RealHeight := ClientHeight - 4;
|
|
|
|
RealWidth := ClientWidth - 4;
|
|
|
|
end else begin
|
|
|
|
RealHeight := Round(RenderBmp.Height * ZOOM_FACTOR_VALUES[ZoomFactor]);
|
|
|
|
RealWidth := Round(RenderBmp.Width * ZOOM_FACTOR_VALUES[ZoomFactor]);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
if (RealWidth > ClientWidth) or (RealHeight > ClientHeight) then begin
|
|
|
|
NeedRecreate := False;
|
2016-06-21 15:12:38 +00:00
|
|
|
Style := GetWindowLong(Handle, GWL_STYLE);
|
|
|
|
if (Style and WS_HSCROLL = 0) and (RealWidth > ClientWidth) then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
Style := Style or WS_HSCROLL;
|
|
|
|
FNeedHScroll := True;
|
|
|
|
NeedRecreate := True;
|
|
|
|
end;
|
2016-06-21 15:12:38 +00:00
|
|
|
if (Style and WS_VSCROLL = 0) and (RealHeight > ClientHeight) then begin
|
2008-02-03 12:05:55 +00:00
|
|
|
Style := Style or WS_VSCROLL;
|
|
|
|
FNeedVScroll := True;
|
|
|
|
NeedRecreate := True;
|
|
|
|
end;
|
|
|
|
if NeedRecreate then begin
|
2016-06-21 15:12:38 +00:00
|
|
|
SetWindowLong(Handle, GWL_STYLE, Style);
|
2008-02-03 12:05:55 +00:00
|
|
|
RecreateWnd{$IFDEF LCL}(Self){$ENDIF};
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if (RealWidth > ClientWidth) then
|
2016-06-21 15:12:38 +00:00
|
|
|
InitHScrollBar(ClientWidth, RealWidth)
|
2008-02-03 12:05:55 +00:00
|
|
|
else
|
|
|
|
RemoveHScrollbar;
|
|
|
|
|
|
|
|
if (RealHeight > ClientHeight) then
|
2016-06-21 15:12:38 +00:00
|
|
|
InitVScrollBar(ClientHeight, RealHeight)
|
2008-02-03 12:05:55 +00:00
|
|
|
else
|
|
|
|
RemoveVScrollbar;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.SetStartDate(const v: TDateTime);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if v <> FStartDate then begin
|
|
|
|
FStartDate := v;
|
|
|
|
ClearPageData;
|
|
|
|
GeneratePageImage;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.SetZoomFactor(const v: TVpPPZoomFactor);
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
if v <> FZoomFactor then begin
|
|
|
|
FZoomFactor := v;
|
|
|
|
SetScrollBars;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{$IFNDEF LCL}
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.VpPrintFormatChanged(var Msg: {$IFNDEF LCL}TMessage{$ELSE}TLMessage{$ENDIF});
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
ForceUpdate;
|
|
|
|
end;
|
|
|
|
{$ENDIF}
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.WMEraseBackground(var Msg: {$IFDEF DELPHI}TWMERASEBKGND){$ELSE}TLMERASEBKGND){$ENDIF};
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
Msg.Result := 1;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.WMVScroll(var Msg: {$IFDEF DELPHI}TWMSCROLL){$ELSE}TLMSCROLL{$ENDIF});
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-06-21 15:12:38 +00:00
|
|
|
DoScroll(Msg, SB_VERT);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.WMHScroll(var Msg: {$IFDEF DELPHI}TWMSCROLL){$ELSE}TLMSCROLL){$ENDIF};
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
2016-06-21 15:12:38 +00:00
|
|
|
DoScroll(Msg, SB_HORZ);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
procedure TVpPrintPreview.WMRButtonDown(var Msg: {$IFDEF DELPHI}TWMRButtonDown{$ELSE}TLMRButtonDown{$ENDIF});
|
2008-02-03 12:05:55 +00:00
|
|
|
var
|
2016-06-21 15:12:38 +00:00
|
|
|
ClientOrigin: TPoint;
|
|
|
|
i: Integer;
|
2008-02-03 12:05:55 +00:00
|
|
|
begin
|
|
|
|
inherited;
|
|
|
|
|
|
|
|
if not Assigned (PopupMenu) then begin
|
2016-06-21 15:12:38 +00:00
|
|
|
if not Focused then
|
2008-02-03 12:05:55 +00:00
|
|
|
SetFocus;
|
|
|
|
ClientOrigin := GetClientOrigin;
|
|
|
|
|
|
|
|
for i := 0 to FDefaultPopup.Items.Count - 1 do begin
|
|
|
|
FDefaultPopup.Items[i].Enabled := True;
|
|
|
|
if (FDefaultPopup.Items[i].Tag = 1) and (IsFirstPage) then
|
|
|
|
FDefaultPopup.Items[i].Enabled := False;
|
|
|
|
if (FDefaultPopup.Items[i].Tag = 2) and (IsLastPage) then
|
|
|
|
FDefaultPopup.Items[i].Enabled := False;
|
|
|
|
end;
|
|
|
|
|
2016-06-21 15:12:38 +00:00
|
|
|
FDefaultPopup.Popup(Msg.XPos + ClientOrigin.x, Msg.YPos + ClientOrigin.y);
|
2008-02-03 12:05:55 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
end.
|
|
|
|
|