Skip to main navigation Zum Hauptinhalt springen Skip to page footer
// {$I RLReport.inc}
unit RLPreviewForm;

interface

uses
  Windows, Messages, SysUtils, Math, Contnrs, Classes, ComCtrls, Types, Controls, Forms, Dialogs, Vcl.VirtualImageList,
  SVGIconVirtualImageList, Vcl.BaseImageCollection, SVGIconImageCollection, Vcl.ExtCtrls, Vcl.StdCtrls, Vcl.Buttons,
  Graphics, TL.Components, Vcl.Printers, System.StrUtils,

  RLConsts, RLMetaFile, RLPreview, RLFilters, RLUtils, RLPrintDialog, RLSaveDialog, RLPrinters, RLTypes, RLFindDialog,
  RLComponentFactory, RLAbout, RLSpoolFilter, RLPDFFilter, System.ImageList, Vcl.ImgList, Vcl.Samples.Spin;

type
  TRLPreviewForm = class(TLForm)
    ButtonAfdrukken: TButton;
    ButtonAnnuleren: TButton;
    ComboBoxDuplex: TComboBox;
    ComboBoxPrinter: TComboBoxEx;
    ComboBoxZoom: TComboBox;
    EditPageNo: TEdit;
    EditPageSelection: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label5: TLabel;
    Label6: TLabel;
    PanelComboBoxZoom: TPanel;
    PanelContainer: TPanel;
    PanelEditPageNo: TPanel;
    PanelLeft: TPanel;
    PanelOf: TPanel;
    PanelPage: TPanel;
    PanelPageCount: TPanel;
    PanelRight: TPanel;
    PanelTools: TPanel;
    RadioGroupLayout: TRadioGroup;
    RadioGroupPages: TRadioGroup;
    SVGIconImageCollection: TSVGIconImageCollection;
    SVGIconImageCollectionPrinter: TSVGIconImageCollection;
    SVGIconVirtualImageList: TSVGIconVirtualImageList;
    SVGIconVirtualImageListPrinter: TSVGIconVirtualImageList;
    SpeedButtonFirst: TSpeedButton;
    SpeedButtonLast: TSpeedButton;
    SpeedButtonNext: TSpeedButton;
    SpeedButtonPrior: TSpeedButton;
    SpeedButtonSearch: TSpeedButton;
    SpeedButtonViews: TSpeedButton;
    SpeedButtonZoomDown: TSpeedButton;
    SpeedButtonZoomUp: TSpeedButton;
    SpinEditCopies: TSpinEdit;
    procedure ButtonAnnulerenClick(Sender: TObject);
    procedure ComboBoxDuplexChange(Sender: TObject);
    procedure ComboBoxDuplexDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState);
    procedure ComboBoxPrinterChange(Sender: TObject);
    procedure ComboBoxZoomChange(Sender: TObject);
    procedure EditPageSelectionChange(Sender: TObject);
    procedure EditPageNoChange(Sender: TObject);
    procedure FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
    procedure FormResize(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure SpeedButtonAfdrukkenClick(Sender: TObject);
    procedure SpeedButtonEditClick(Sender: TObject);
    procedure SpeedButtonFirstClick(Sender: TObject);
    procedure SpeedButtonLastClick(Sender: TObject);
    procedure SpeedButtonSaveClick(Sender: TObject);
    procedure SpeedButtonSearchClick(Sender: TObject);
    procedure SpeedButtonSendClick(Sender: TObject);
    procedure SpeedButtonViewsClick(Sender: TObject);
    procedure SpeedButtonZoomDownClick(Sender: TObject);
    procedure SpeedButtonZoomUpClick(Sender: TObject);
    procedure rpvDefaultChangeView(Sender: TObject);
    procedure SpinEditCopiesChange(Sender: TObject);
  private
    { Private declarations }
    FEditingPageNo: Boolean;
    FEditingZoom: Boolean;
    FFindDialog: TfrmRLFindDialog;
    FPreviewIndex: Integer;
    FPreviewList: TObjectList;
    FSpeedButtonCustomAction: TSpeedButton;

    Device, Driver, Port: string;
    hDeviceMode: THandle;
    printCommand: string;
    printerInfo: string;

    SpeedButtonWidth: Integer;
    ToolBarHeight: Integer;
    ToolbarWidth: Integer;

    procedure WMActivate(var Message: TWMActivate); message WM_ACTIVATE;

    procedure InitIcons(var SVGIconVirtualImageList: TSVGIconVirtualImageList);

    function InitLabel(ATop: Integer; ACaption: string): TLabel;
    function InitPanel(AParent: TWinControl; AName: string; ALeft, AWidth: Integer; ACaption: string;
      AAlign: TAlign): TPanel;
    function InitRadioGroup(ATop, Aheight: Integer): TRadioGroup;
    function InitSpeedButton(AName: string; ALeft, AWidth: Integer; ACaption: string; AImage: string;
      AOnClick: TNotifyEvent): TSpeedButton;

    procedure Init;
    procedure NewPreview;
    procedure ReleasePreview;
    procedure OrganizePreviews;
    procedure SetPreview(APreview: TRLPreview);
    function GetPreview: TRLPreview;
    procedure PreviewEnter(Sender: TObject);
    procedure CreateShortCuts;
    procedure UpdateComboBoxZoom;
    procedure UpdateEditPageNo;
    procedure ShowFindDialog;
    procedure OnFindHandler(Sender: TObject; const AText: string; Options: TRLFindOptions; var Found: Boolean);
    procedure CMMouseWheel(var Message: TCMMouseWheel); message CM_MOUSEWHEEL;
  protected
    { Protected declarations }
    procedure DoClose(var Action: TCloseAction); override;
    procedure CreateParams(var Params: TCreateParams); override;
    procedure OnClickRLAbout(Sender: TObject);
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); reintroduce;
    destructor Destroy; override;
    procedure SpeedButtonNextClick(Sender: TObject);
    procedure SpeedButtonPriorClick(Sender: TObject);
    property Preview: TRLPreview read GetPreview;
  end;

  TRLPreviewFormButtons = (pbPrint, pbSave, pbSend, pbCustom);
  TRLPreviewFormButtonsSet = set of TRLPreviewFormButtons;
  TRLPreviewEditOptions = (eoCanReposition, eoCanResizeItems, eoCanEditText, eoCanDeleteItems, eoCanPointOut);
  TRLPreviewEditOptionsSet = set of TRLPreviewEditOptions;

  { Standaard preview-opties.
    Rapporten die geen eigen preview-instellingen hebben,
    volgen de regels die in dit onderdeel worden beschreven. }

  [ComponentPlatformsAttribute(pidWin32 or pidWin64)]
  TRLPreviewSetup = class(TComponent)
  private
    FBeforePrint: TNotifyEvent;
    FAfterPrint: TNotifyEvent;
    FBeforeSave: TNotifyEvent;
    FAfterSave: TNotifyEvent;
    FBeforeSend: TNotifyEvent;
    FOnSend: TNotifyEvent;
    FAfterSend: TNotifyEvent;
    FEnabledButtons: TRLPreviewFormButtonsSet;
    FEditOptions: TRLPreviewEditOptionsSet;
    FCustomActionText: string;
    FOnCustomAction: TNotifyEvent;
    function GetBorderIcons: TBorderIcons;
    function GetCaption: string;
    function GetFormStyle: TFormStyle;
    function GetHelpContext: Integer;
    function GetHelpFile: string;
    function GetPosition: TPosition;
    function GetSentToPrinter: Boolean;
    function GetShowModal: Boolean;
    function GetWindowBounds: TRect;
    function GetWindowState: TWindowState;
    function GetZoomFactor: Double;
    procedure SetBorderIcons(const Value: TBorderIcons);
    procedure SetCaption(const Value: string);
    procedure SetFormStyle(const Value: TFormStyle);
    procedure SetHelpContext(const Value: Integer);
    procedure SetHelpFile(const Value: string);
    procedure SetPosition(const Value: TPosition);
    procedure SetSentToPrinter(const Value: Boolean);
    procedure SetShowModal(const Value: Boolean);
    procedure SetWindowBounds(const Value: TRect);
    procedure SetWindowState(const Value: TWindowState);
    procedure SetZoomFactor(const Value: Double);
    function IsZoomFactor: Boolean;
    procedure SetEnabledButtons(const Value: TRLPreviewFormButtonsSet);
    procedure SetEditOptions(const Value: TRLPreviewEditOptionsSet);
  public
    { Public declarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;

    { Geeft aan of het rapport minstens één keer is afgedrukt. :/ }
    property SentToPrinter: Boolean read GetSentToPrinter write SetSentToPrinter;

    { Specificeert of bepaalt de standaardafmetingen van het venster wanneer het niet gemaximaliseerd is. :/ }
    property WindowBounds: TRect read GetWindowBounds write SetWindowBounds;
  published
    { Geeft de begintoestand van het voorbeeldvenster aan. :/ }
    property WindowState: TWindowState read GetWindowState write SetWindowState default wsMaximized;

    { Geeft de stijl van het voorbeeldvenster aan. :/ }
    property FormStyle: TFormStyle read GetFormStyle write SetFormStyle default fsNormal;

    { Geeft aan of het voorbeeldvenster modaal wordt weergegeven. :/ }
    property ShowModal: Boolean read GetShowModal write SetShowModal default False;

    { Geeft de positie van het voorbeeldvenster aan. :/ }
    property Position: TPosition read GetPosition write SetPosition default poScreenCenter;

    { Selecteert de knoppen in het voorbeeldvenster. :/ }
    property BorderIcons: TBorderIcons read GetBorderIcons write SetBorderIcons
      default [biSystemMenu, biMinimize, biMaximize];

    { Naam van het helpbestand voor het voorbeeldvenster, indien aanwezig. :/ }
    property HelpFile: string read GetHelpFile write SetHelpFile;

    { Helpcontext voor het voorbeeldvenster, indien aanwezig. :/ }
    property HelpContext: Integer read GetHelpContext write SetHelpContext default 0;

    { Titel van het voorbeeldvenster. :/ }
    property Caption: string read GetCaption write SetCaption;

    { Initiële zoomfactor (percentage). :/ }
    property ZoomFactor: Double read GetZoomFactor write SetZoomFactor stored IsZoomFactor;

    { Ingeschakelde knoppen.
      Met deze prop kun je knoppen op de werkbalk weergeven of verbergen.
      @links TRLPreviewFormButtonsSet. :/ }
    property EnabledButtons: TRLPreviewFormButtonsSet read FEnabledButtons write SetEnabledButtons
      default [pbPrint, pbSave, pbSend];

    property CustomActionText: string read FCustomActionText write FCustomActionText;
    property OnCustomAction: TNotifyEvent read FOnCustomAction write FOnCustomAction;

    { Bewerkingsopties (nog niet beschikbaar).
      Bepaalt welke bewerkingen door de gebruiker kunnen worden uitgevoerd op de inhoud van het
      reeds voorbereide rapport.
      @links TRLPreviewEditOptions,TRLPreviewEditOptionsSet. :/ }
    property EditOptions: TRLPreviewEditOptionsSet read FEditOptions write SetEditOptions default [];

    { Altijd vóór het afdrukken of wanneer de gebruiker op de knop "Afdrukken" drukt. :/ }
    property BeforePrint: TNotifyEvent read FBeforePrint write FBeforePrint;

    { Altijd na het afdrukken of wanneer het afdrukfilter alle pagina's heeft verwerkt. :/ }
    property AfterPrint: TNotifyEvent read FAfterPrint write FAfterPrint;

    { Altijd vóór het opslaan/exporteren of wanneer de gebruiker op de knop "Opslaan" klikt. :/ }
    property BeforeSave: TNotifyEvent read FBeforeSave write FBeforeSave;

    { Altijd na het opslaan/exporteren of wanneer het opslagfilter alle pagina's heeft verwerkt. :/ }
    property AfterSave: TNotifyEvent read FAfterSave write FAfterSave;

    { Altijd voordat het rapport via e-mail wordt verzonden of wanneer de gebruiker op de knop 'Verzenden' klikt. :/ }
    property BeforeSend: TNotifyEvent read FBeforeSend write FBeforeSend;

    { Altijd bij het verzenden van een rapport via e-mail.
      De programmeur moet deze gebeurtenis implementeren en ervoor zorgen dat het rapport wordt verzonden.
      FortesReport biedt deze routine niet, maar alleen de interface ervoor }
    property OnSend: TNotifyEvent read FOnSend write FOnSend;

    { Altijd nadat het rapport via e-mail is verzonden. :/ }
    property AfterSend: TNotifyEvent read FAfterSend write FAfterSend;
  end;

const
  ZoomFactorFullWidth = -1;
  ZoomFactorFullPage = -2;
  ZoomFactorMultiplePages = -3;

type
  TOnCreatePreviewFormProc = procedure(PreviewForm: TRLPreviewForm);

var
  DefaultWindowState: TWindowState = wsMaximized;
  DefaultWindowBounds: TRect;
  DefaultFormStyle: TFormStyle = fsNormal;
  DefaultShowModal: Boolean = False;
  DefaultPosition: TPosition = poScreenCenter;
  DefaultBorderIcons: TBorderIcons = [biSystemMenu, biMinimize, biMaximize];
  DefaultHelpFile: string = '';
  DefaultHelpContext: Integer = 0;
  DefaultCaption: string = '';
  DefaultZoomFactor: Double = 100;
  SentToPrinter: Boolean = False;
  OnCreatePreviewForm: TOnCreatePreviewFormProc = nil;
  ShowPreviewOnWindowsTaskBar: Boolean = False;

  { Geeft het standaardvoorbeeldformulier weer met opties }
procedure PreviewPagesWithOptions(APages: TRLGraphicStorage; AShowModal: Boolean; AFormStyle: TFormStyle;
  APosition: TPosition; AWindowState: TWindowState; ABorderIcons: TBorderIcons; const AHelpFile: string;
  AHelpContext: Integer; ACaption: TCaption);

{ Geeft het standaardvoorbeeldformulier weer met standaardopties }
procedure PreviewPages(APages: TRLGraphicStorage);

{ Laadt het rapportbestand en geeft het standaardvoorbeeldformulier weer }
procedure PreviewFromFile(const AFileName: string);

{ Laadt de rapportstream en geeft het standaardvoorbeeldformulier weer }
procedure PreviewFromStream(AStream: TStream);

{ Geeft een dialoogvenster weer voor het laden van een rapportbestand en
  geeft het standaardvoorbeeld weer }
procedure PreviewFromFileDialog;

implementation

{$R *.dfm}

var
  SetupInstance: TRLPreviewSetup = nil;

procedure PreviewPagesWithOptions(APages: TRLGraphicStorage; AShowModal: Boolean; AFormStyle: TFormStyle;
  APosition: TPosition; AWindowState: TWindowState; ABorderIcons: TBorderIcons; const AHelpFile: string;
  AHelpContext: Integer; ACaption: TCaption);
begin
  SentToPrinter:= False;
  with TRLPreviewForm.Create(nil) do
    begin
      name:= 'frmPreview';
      Preview.Pages:= APages;
      if DefaultZoomFactor = ZoomFactorFullWidth then
        Preview.ZoomFullWidth
      else if DefaultZoomFactor = ZoomFactorFullPage then
        Preview.ZoomFullPage
      else if DefaultZoomFactor = ZoomFactorMultiplePages then
        Preview.ZoomMultiplePages
      else if DefaultZoomFactor > 0 then
        Preview.ZoomFactor:= DefaultZoomFactor;
      UpdateComboBoxZoom;

      { Will be handled bij TLForm }
      // Position:= APosition;
      // WindowState:= AWindowState;

      BorderIcons:= ABorderIcons;
      HelpFile:= AHelpFile;
      HelpContext:= AHelpContext;
      if ACaption <> '' then
        Caption:= ACaption;
      FormStyle:= AFormStyle;
      if AShowModal then
        ShowModal
      else if Visible then
        BringToFront
      else
        Show;
    end;
end;

procedure PreviewPages(APages: TRLGraphicStorage);
begin
  PreviewPagesWithOptions(APages, DefaultShowModal, DefaultFormStyle, DefaultPosition, DefaultWindowState,
    DefaultBorderIcons, DefaultHelpFile, DefaultHelpContext, DefaultCaption);
end;

procedure PreviewFromFile(const AFileName: string);
var
  savecursor: TCursor;
  Pages: TRLGraphicStorage;
begin
  if not FileExists(AFileName) then
    raise Exception.Create(GetLocalizeStr(LocaleStrings.LS_FileNotFoundStr + ' "' + AFileName + '"'));
  Pages:= TRLGraphicStorage.Create;
  try
    savecursor:= Screen.Cursor;
    Screen.Cursor:= crHourGlass;
    try
      Pages.LoadFromFile(AFileName);
    finally
      Screen.Cursor:= savecursor;
    end;
    PreviewPages(Pages);
  finally
    Pages.Unlink;
  end;
end;

procedure PreviewFromStream(AStream: TStream);
var
  savecursor: TCursor;
  Pages: TRLGraphicStorage;
begin
  Pages:= TRLGraphicStorage.Create;
  try
    savecursor:= Screen.Cursor;
    Screen.Cursor:= crHourGlass;
    try
      Pages.LoadFromStream(AStream);
    finally
      Screen.Cursor:= savecursor;
    end;
    PreviewPages(Pages);
  finally
    Pages.Unlink;
  end;
end;

procedure PreviewFromFileDialog;
var
  OpenDialog: TOpenDialog;
begin
  TRLComponentFactory.CreateComponent(TOpenDialog, nil, OpenDialog);
  with OpenDialog do
    try
      DefaultExt:= FormatFileExt(ReportFileExt);
      Filter:= AddFileFilter('', CS_ProductTitleStr, ReportFileExt);
      FilterIndex:= 1;
      Title:= GetLocalizeStr(LocaleStrings.LS_LoadReportStr);
      if Execute then
        PreviewFromFile(FileName);
    finally
      Free;
    end;
end;

constructor TRLPreviewForm.Create(AOwner: TComponent);
begin
  DoCreate;
  if ShowPreviewOnWindowsTaskBar then
    ParentWindow:= 0;
  FPreviewList:= nil;
  FPreviewIndex:= 0;
  FEditingZoom:= False;
  FEditingPageNo:= False;
  FFindDialog:= nil;
  FSpeedButtonCustomAction:= nil;
  inherited CreateNew(AOwner);
  FPreviewList:= TObjectList.Create;
  Init;
  CreateShortCuts;
  NewPreview;
  OrganizePreviews;
end;

destructor TRLPreviewForm.Destroy;
begin
  // DoDestroy;
  FPreviewList.Free;
  if Assigned(FFindDialog) then
    FFindDialog.Free;
  inherited;
end;

procedure TRLPreviewForm.CreateShortCuts;
var
  L: TStringList;
  B: TSpeedButton;
  ch: Char;
  K, N: string;
  I, J: Integer;
  function IsValidCaption(const ACaption: string): Boolean;
  var
    I: Integer;
  begin
    Result:= False;
    for I:= 1 to Length(ACaption) do
      if CharInSet(ACaption[I], ['A' .. 'Z', 'a' .. 'z', '0' .. '9']) then
        begin
          Result:= True;
          Break;
        end;
  end;

begin
  L:= TStringList.Create;
  try
    //
    for I:= 0 to ComponentCount - 1 do
      if Components[I] is TSpeedButton then
        begin
          B:= TSpeedButton(Components[I]);
          if IsValidCaption(B.Caption) then
            L.AddObject(B.Caption, B);
        end;
    K:= '';
    for I:= 0 to L.Count - 1 do
      begin
        N:= L[I];
        for J:= 1 to Length(N) do
          begin
            ch:= UpCase(N[J]);
            if CharInSet(ch, ['A' .. 'Z', '0' .. '9']) and (Pos(ch, K) = 0) then
              begin
                Insert('&', N, J);
                L[I]:= N;
                K:= K + ch;
                Break;
              end;
          end;
      end;
    for I:= 0 to L.Count - 1 do
      TSpeedButton(L.Objects[I]).Caption:= L[I];
  finally
    L.Free;
  end;
end;

procedure TRLPreviewForm.OrganizePreviews;
var
  I, T, W: Integer;
  N: TControl;
  S: TSplitter;
begin
  if FPreviewList.Count > 0 then
    begin
      for I:= FPreviewList.Count - 1 downto 0 do
        begin
          N:= TControl(TRLPreview(FPreviewList[I]));
          S:= TSplitter(N.Tag);
          S.Align:= alNone;
          N.Align:= alNone;
        end;
      W:= ClientHeight div FPreviewList.Count;
      T:= 0;
      for I:= 0 to FPreviewList.Count - 1 do
        begin
          N:= TControl(TRLPreview(FPreviewList[I]));
          S:= TSplitter(N.Tag);
          N.Height:= W;
          if I = FPreviewList.Count - 1 then
            begin
              N.Align:= alClient;
              S.Hide;
            end
          else
            begin
              N.Align:= alTop;
              N.Height:= W;
              N.Top:= T;
              Inc(T, N.Height);
              S.Align:= alTop;
              S.Height:= 3;
              S.Visible:= True;
              S.Top:= T;
              Inc(T, S.Height);
            end;
        end;
    end;
end;

procedure TRLPreviewForm.NewPreview;
var
  N: TRLPreview;
  S: TSplitter;
begin
  N:= TRLPreview.Create(nil);
  with N do
    begin
      Width:= 0;
      OnChangeView:= rpvDefaultChangeView;
      OnEnter:= PreviewEnter;
    end;
  TControl(N).Parent:= PanelContainer;
  TRLComponentFactory.CreateComponent(TSplitter, Self, S);
  with S do
    begin
      AutoSnap:= False;
      Width:= 0;
      Parent:= PanelContainer;
    end;
  N.Tag:= PtrInt(S);
  FPreviewList.Add(N);
  if FPreviewList.Count > 1 then
    N.Pages:= TRLPreview(FPreviewList[0]).Pages;
end;

procedure TRLPreviewForm.ReleasePreview;
begin
  if FPreviewList.Count > 1 then
    begin
      FPreviewList.Delete(FPreviewList.Count - 1);
      if FPreviewIndex > FPreviewList.Count - 1 then
        SetPreview(TRLPreview(FPreviewList[FPreviewList.Count - 1]));
    end;
end;

procedure TRLPreviewForm.InitIcons(var SVGIconVirtualImageList: TSVGIconVirtualImageList);
var
  SvgIconItem: TSVGIconItem;
begin
  SVGIconImageCollection:= TSVGIconImageCollection.Create(nil);
  SvgIconItem:= SVGIconImageCollection.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'actions-caret-bar-left';
      SVGText:= // the text of image in SVG format
        '<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools --> '
        + '<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> ' +
        '<path d="M10 12L9.64645 11.6464L9.29289 12L9.64645 12.3536L10 12ZM20 12.5C20.2761 12.5 20.5 12.2761 20.5 12C20.5 11.7239 20.2761 11.5 20 11.5V12.5ZM15.6464 5.64645L9.64645 11.6464L10.3536 12.3536L16.3536 6.35355L15.6464 5.64645ZM9.64645 12.3536L15.6464 18.3536L16.3536 17.6464L10.3536 11.6464L9.64645 12.3536ZM10 12.5H20V11.5H10V12.5Z" fill="#222222"/> '
        + '<path d="M4 5L4 19" stroke="#222222"/> ' + '</svg> ';
    end;
  SvgIconItem:= SVGIconImageCollection.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'actions-caret-bar-right';
      SVGText:= '<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools --> '
        + '<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> ' +
        '<path d="M14 12L14.3536 11.6464L14.7071 12L14.3536 12.3536L14 12ZM4 12.5C3.72386 12.5 3.5 12.2761 3.5 12C3.5 11.7239 3.72386 11.5 4 11.5V12.5ZM8.35355 5.64645L14.3536 11.6464L13.6464 12.3536L7.64645 6.35355L8.35355 5.64645ZM14.3536 12.3536L8.35355 18.3536L7.64645 17.6464L13.6464 11.6464L14.3536 12.3536ZM14 12.5H4V11.5H14V12.5Z" fill="#222222"/> '
        + '<path d="M20 5L20 19" stroke="#222222"/> ' + '</svg> ';
    end;
  SvgIconItem:= SVGIconImageCollection.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'actions-caret-left';
      SVGText:= '<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools --> '
        + '<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> ' +
        '<path d="M4 12L3.64645 11.6464L3.29289 12L3.64645 12.3536L4 12ZM19 12.5C19.2761 12.5 19.5 12.2761 19.5 12C19.5 11.7239 19.2761 11.5 19 11.5V12.5ZM9.64645 5.64645L3.64645 11.6464L4.35355 12.3536L10.3536 6.35355L9.64645 5.64645ZM3.64645 12.3536L9.64645 18.3536L10.3536 17.6464L4.35355 11.6464L3.64645 12.3536ZM4 12.5H19V11.5H4V12.5Z" fill="#222222"/> '
        + '</svg> ';
    end;
  SvgIconItem:= SVGIconImageCollection.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'actions-caret-right';
      SVGText:= '<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools --> '
        + '<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> ' +
        '<path d="M20 12L20.3536 11.6464L20.7071 12L20.3536 12.3536L20 12ZM5 12.5C4.72386 12.5 4.5 12.2761 4.5 12C4.5 11.7239 4.72386 11.5 5 11.5V12.5ZM14.3536 5.64645L20.3536 11.6464L19.6464 12.3536L13.6464 6.35355L14.3536 5.64645ZM20.3536 12.3536L14.3536 18.3536L13.6464 17.6464L19.6464 11.6464L20.3536 12.3536ZM20 12.5H5V11.5H20V12.5Z" fill="#222222"/> '
        + '</svg> ';
    end;
  SvgIconItem:= SVGIconImageCollection.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'zoom-in';
      SVGText:= '<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" '
        + '	 width="800px" height="800px" viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve"> '
        + '<g> ' +
        '	<line fill="none" stroke="#000000" stroke-width="2" stroke-miterlimit="10" x1="12" y1="21" x2="30" y2="21"/> '
        + '	<line fill="none" stroke="#000000" stroke-width="2" stroke-miterlimit="10" x1="21" y1="12" x2="21" y2="30"/> '
        + '</g> ' + '<g> ' +
        '	<circle fill="none" stroke="#000000" stroke-width="2" stroke-miterlimit="10" cx="21" cy="21" r="20"/> ' +
        '	<line fill="none" stroke="#000000" stroke-width="2" stroke-miterlimit="10" x1="35" y1="35" x2="41" y2="41"/> '
        + ' ' + '		<rect x="46.257" y="37.065" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 121.9178 50.5)" fill="none" stroke="#000000" stroke-width="2" stroke-miterlimit="10" width="8.485" height="26.87"/> '
        + '</g> ' + '</svg> ';

    end;
  SvgIconItem:= SVGIconImageCollection.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'zoom-out';
      SVGText:= '<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" '
        + '	 width="800px" height="800px" viewBox="0 0 64 64" enable-background="new 0 0 64 64" xml:space="preserve"> '
        + '<g> ' +
        '	<line fill="none" stroke="#000000" stroke-width="2" stroke-miterlimit="10" x1="12" y1="21" x2="30" y2="21"/> '
        + '</g> ' + '<g> ' +
        '	<circle fill="none" stroke="#000000" stroke-width="2" stroke-miterlimit="10" cx="21" cy="21" r="20"/> ' +
        '	<line fill="none" stroke="#000000" stroke-width="2" stroke-miterlimit="10" x1="35" y1="35" x2="41" y2="41"/> '
        + ' ' + '		<rect x="46.257" y="37.065" transform="matrix(-0.7071 0.7071 -0.7071 -0.7071 121.9178 50.5)" fill="none" stroke="#000000" stroke-width="2" stroke-miterlimit="10" width="8.485" height="26.87"/> '
        + '</g> ' + '</svg> ';

    end;
  SvgIconItem:= SVGIconImageCollection.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'component-divider-vertical';
      SVGText:= '<svg height="800px" width="800px" version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" '
        + '	 viewBox="0 0 513.151 513.151" xml:space="preserve"> ' + '<g> ' +
        '	<path style="fill:#010002;" d="M466.985,166.637c-0.036-0.531-0.137-1.044-0.31-1.545c-0.066-0.191-0.113-0.37-0.197-0.555 '
        + '		c-0.292-0.632-0.656-1.235-1.169-1.748L304.269,1.742c-0.513-0.513-1.11-0.877-1.742-1.164c-0.185-0.09-0.376-0.137-0.573-0.203 '
        + '		c-0.495-0.167-0.991-0.269-1.51-0.298C300.307,0.066,300.187,0,300.056,0H135.597c-3.294,0-5.967,2.673-5.967,5.967v70.111H52.061 '
        + '		c-3.294,0-5.967,2.673-5.967,5.967v425.139c0,3.3,2.673,5.967,5.967,5.967h325.493c3.3,0,5.967-2.667,5.967-5.967v-70.111h77.569 '
        + '		c3.3,0,5.967-2.667,5.967-5.967V167.001C467.057,166.875,466.991,166.762,466.985,166.637z M141.564,11.928h152.519v139.243 '
        + '		L220.732,77.82c-0.513-0.513-1.11-0.877-1.742-1.164c-0.185-0.09-0.376-0.137-0.573-0.203c-0.495-0.167-0.991-0.269-1.51-0.298 '
        + '		c-0.137-0.012-0.257-0.078-0.388-0.078h-74.956V11.928z M371.587,425.134v11.934v64.144H58.028V88.005h71.602h11.934h68.983 '
        + '		v155.073c0,3.294,2.673,5.967,5.967,5.967h155.073V425.134z M455.123,425.134h-71.602V243.078c0-0.125-0.066-0.239-0.072-0.364 '
        + '		c-0.036-0.531-0.137-1.044-0.31-1.545c-0.066-0.191-0.113-0.37-0.197-0.555c-0.292-0.632-0.656-1.235-1.169-1.748l-65.892-65.898 '
        + '		h139.243V425.134z"/> ' + '</g> ' + '</svg> ';

    end;
  SvgIconItem:= SVGIconImageCollection.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'print-outline';
      SVGText:= '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"' +
        ' viewBox="0 0 24 24"><path fill="currentColor" d="M16 8.616v-3H8' +
        'v3H7v-4h10v4zm-11.423 1h14.846zm13.038 2.5q.425 0 .713-.288t.287' +
        '-.712t-.287-.713t-.713-.288t-.712.288t-.288.713t.288.712t.713.28' +
        '8M16 19v-4.538H8V19zm1 1H7v-4H3.577v-5.384q0-.85.577-1.425t1.423' +
        '-.576h12.846q.85 0 1.425.576t.575 1.424V16H17zm2.423-5v-4.384q0-' +
        '.425-.287-.713t-.713-.288H5.577q-.425 0-.712.288t-.288.713V15H7v' + '-1.538h10V15z"/></svg>';
    end;
  SvgIconItem:= SVGIconImageCollection.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'find-filled';
      SVGText:= '<svg width="800px" height="800px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M17 16h-5.525a5.95 5.95 0 0 0-.172-1H17zm2-7h-9v1h9zm0 3h-9v.544q.193.22.364.456H19zm3 8H11.818l-.913-.913c.014-.028.023-.059.037-.087H21V7h-4V3H8v8.053a5.945 5.945 0 0 0-1-.356V2h11.4L22 5.6zM21 5.69L18.31 3H18v3h3zM8.926 19.23l3.085 3.084a.476.476 0 0 1 0 .674l-.017.017a.476.476 0 0 1-.673 0L8.237 19.92A4.383 4.383 0 1 1 9.9 16.5a4.358 4.358 0 0 1-.974 2.73zM5.5 19.9a3.4 3.4 0 1 0-3.4-3.4 3.404 3.404 0 0 0 3.4 3.4z"/><path fill="none" d="M0 0h24v24H0z"/></svg> ';
    end;
  SvgIconItem:= SVGIconImageCollection.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'save';
      SVGText:= '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"' +
        ' viewBox="0 0 32 32"><path fill="currentColor" d="m27.71 9.29l-5' +
        '-5A1 1 0 0 0 22 4H6a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h20a2 2 0 0 0 ' +
        '2-2V10a1 1 0 0 0-.29-.71M12 6h8v4h-8Zm8 20h-8v-8h8Zm2 0v-8a2 2 0' +
        ' 0 0-2-2h-8a2 2 0 0 0-2 2v8H6V6h4v4a2 2 0 0 0 2 2h8a2 2 0 0 0 2-' + '2V6.41l4 4V26Z"/></svg>';
    end;
  SvgIconItem:= SVGIconImageCollection.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'close-light';

      SVGText:= '<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em"' +
        ' viewBox="0 0 24 24"><path fill="none" stroke="currentColor" str' +
        'oke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d' + '="m7 7l10 10M7 17L17 7"/></svg>';
    end;

  SVGIconImageCollectionPrinter:= TSVGIconImageCollection.Create(nil);
  // Add SVG icons to the collection
  SvgIconItem:= SVGIconImageCollectionPrinter.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'printer-storing';
      SVGText:= '<svg viewBox="0 0 1024 1024" class="icon" version="1.1" xmlns="h' +
        'ttp://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarri' +
        'er" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-li' +
        'necap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCar' +
        'rier"><path d="M276.8 302.3h470.4v212.3H276.8z" fill="#FFD632"><' +
        '/path><path d="M752.7 520.1H271.3V296.8h481.4v223.3z m-470.4-11h' +
        '459.4V307.8H282.3v201.3z" fill="#333336"></path><path d="M363.8 ' +
        '192.8h296.5v271.6H363.8z" fill="#ECEFE8"></path><path d="M665.7 ' +
        '470H358.3V187.3h307.5V470z m-296.4-11h285.5V198.3H369.3V459z" fi' +
        'll="#333336"></path><path d="M842.7 781.8H181.3c-19.1 0-34.6-15.' +
        '5-34.6-34.6V460.9c0-19.1 15.5-34.6 34.6-34.6h661.4c19.1 0 34.6 1' +
        '5.5 34.6 34.6v286.3c0 19.1-15.5 34.6-34.6 34.6z" fill="#ff0000">' +
        '</path><path d="M842.7 787.3H181.3c-22.1 0-40.1-18-40.1-40.1V460' +
        '.9c0-22.1 18-40.1 40.1-40.1h661.4c22.1 0 40.1 18 40.1 40.1v286.3' +
        'c0 22.1-18 40.1-40.1 40.1zM181.3 431.8c-16 0-29.1 13.1-29.1 29.1' +
        'v286.3c0 16 13.1 29.1 29.1 29.1h661.4c16 0 29.1-13.1 29.1-29.1V4' +
        '60.9c0-16-13.1-29.1-29.1-29.1H181.3z" fill="#333336"></path><pat' +
        'h d="M822 831.2H202l-11.3-49.4h642.6z" fill="#D5D9CF"></path><pa' +
        'th d="M826.4 836.7H197.6l-13.7-60.4h656.3l-13.8 60.4z m-620-11h6' +
        '11.3l8.7-38.4H197.6l8.8 38.4z" fill="#333336"></path><path d="M7' +
        '58.5 781.8h-493V667.1c0-19.7 16-35.7 35.7-35.7h421.6c19.7 0 35.7' +
        ' 16 35.7 35.7v114.7z" fill="#D5D9CF"></path><path d="M764 787.3H' +
        '260V667.1c0-22.7 18.5-41.2 41.2-41.2h421.6c22.7 0 41.2 18.5 41.2' +
        ' 41.2v120.2z m-493-11h482V667.1c0-16.6-13.5-30.2-30.2-30.2H301.2' +
        'c-16.6 0-30.2 13.5-30.2 30.2v109.2z" fill="#333336"></path><path' +
        ' d="M265.5 738h493v43.8h-493z" fill="#ff0000"></path><path d="M7' +
        '64 787.3H260v-54.8h504v54.8z m-493-11h482v-32.8H271v32.8z" fill=' +
        '"#333336"></path><path d="M575.2 584.3V482.1c0-12.8 10.4-23.3 23' +
        '.3-23.3h220c12.8 0 23.3 10.4 23.3 23.3v102.1" fill="#FFD632"></p' +
        'ath><path d="M847.2 584.3h-11V482.1c0-9.8-8-17.8-17.8-17.8h-220c' +
        '-9.8 0-17.8 8-17.8 17.8v102.1h-11V482.1c0-15.9 12.9-28.8 28.8-28' +
        '.8h220c15.9 0 28.8 12.9 28.8 28.8v102.2z" fill="#333336"></path>' +
        '<path d="M145.1 578.8h730.6v11H145.1z" fill="#333336"></path><pa' +
        'th d="M784.5 523.1m-23 0a23 23 0 1 0 46 0 23 23 0 1 0-46 0Z" fil' +
        'l="#ECEFE8"></path><path d="M784.5 550.1c-14.9 0-27-12.1-27-27s1' +
        '2.1-27 27-27 27 12.1 27 27-12.1 27-27 27z m0-46c-10.5 0-19 8.5-1' +
        '9 19s8.5 19 19 19 19-8.5 19-19-8.5-19-19-19z" fill="#333336"></p' +
        'ath><path d="M627.7 545.8l-16.6-16.6c-3.6-3.6-3.6-9.4 0-13l16.6-' +
        '16.6c5.8-5.8 15.7-1.7 15.7 6.5v33.2c0 8.2-9.9 12.3-15.7 6.5z" fi' +
        'll="#ECEFE8"></path><path d="M634.1 552.5c-3.4 0-6.7-1.3-9.3-3.9' +
        'L608.2 532c-2.5-2.5-3.9-5.8-3.9-9.3 0-3.5 1.4-6.9 3.9-9.3l16.6-1' +
        '6.6c3.9-3.9 9.4-5 14.4-2.9s8.2 6.8 8.2 12.2v33.2c0 5.4-3.1 10.1-' +
        '8.2 12.2-1.6 0.7-3.4 1-5.1 1z m0-51.7c-1.1 0-2.4 0.3-3.6 1.5L613' +
        '.9 519c-1 1-1.5 2.3-1.5 3.7 0 1.4 0.5 2.7 1.5 3.7l16.6 16.6c2.3 ' +
        '2.3 4.9 1.4 5.7 1.1 0.8-0.3 3.2-1.6 3.2-4.8v-33.2c0-3.2-2.5-4.5-' +
        '3.2-4.8-0.4-0.2-1.1-0.5-2.1-0.5z" fill="#333336"></path><path d=' +
        '"M699 545.8l16.6-16.6c3.6-3.6 3.6-9.4 0-13L699 499.5c-5.8-5.8-15' +
        '.7-1.7-15.7 6.5v33.2c-0.1 8.3 9.8 12.4 15.7 6.6z" fill="#ECEFE8"' +
        '></path><path d="M692.5 552.5c-1.7 0-3.5-0.3-5.1-1-5-2.1-8.2-6.8' +
        '-8.2-12.2v-33.2c0-5.4 3.1-10.1 8.2-12.2 5-2.1 10.6-1 14.4 2.9l16' +
        '.6 16.6c5.2 5.2 5.2 13.5 0 18.7l-16.6 16.6c-2.6 2.5-5.9 3.8-9.3 ' +
        '3.8z m0-51.7c-1 0-1.7 0.3-2.1 0.4-0.8 0.3-3.2 1.6-3.2 4.8v33.2c0' +
        ' 3.2 2.5 4.5 3.2 4.8 0.8 0.3 3.4 1.2 5.7-1.1l16.6-16.6c2-2 2-5.3' +
        ' 0-7.4l-16.6-16.6c-1.2-1.1-2.5-1.5-3.6-1.5z" fill="#333336"></pa' + 'th></g></svg>'

    end;

  SvgIconItem:= SVGIconImageCollectionPrinter.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'printer-beschikbaar';
      SVGText:= '<svg viewBox="0 0 1024 1024" class="icon" version="1.1" xmlns="h' +
        'ttp://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarri' +
        'er" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-li' +
        'necap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCar' +
        'rier"><path d="M276.8 302.3h470.4v212.3H276.8z" fill="#FFD632"><' +
        '/path><path d="M752.7 520.1H271.3V296.8h481.4v223.3z m-470.4-11h' +
        '459.4V307.8H282.3v201.3z" fill="#333336"></path><path d="M363.8 ' +
        '192.8h296.5v271.6H363.8z" fill="#ECEFE8"></path><path d="M665.7 ' +
        '470H358.3V187.3h307.5V470z m-296.4-11h285.5V198.3H369.3V459z" fi' +
        'll="#333336"></path><path d="M842.7 781.8H181.3c-19.1 0-34.6-15.' +
        '5-34.6-34.6V460.9c0-19.1 15.5-34.6 34.6-34.6h661.4c19.1 0 34.6 1' +
        '5.5 34.6 34.6v286.3c0 19.1-15.5 34.6-34.6 34.6z" fill="#68A"></p' +
        'ath><path d="M842.7 787.3H181.3c-22.1 0-40.1-18-40.1-40.1V460.9c' +
        '0-22.1 18-40.1 40.1-40.1h661.4c22.1 0 40.1 18 40.1 40.1v286.3c0 ' +
        '22.1-18 40.1-40.1 40.1zM181.3 431.8c-16 0-29.1 13.1-29.1 29.1v28' +
        '6.3c0 16 13.1 29.1 29.1 29.1h661.4c16 0 29.1-13.1 29.1-29.1V460.' +
        '9c0-16-13.1-29.1-29.1-29.1H181.3z" fill="#333336"></path><path d' +
        '="M822 831.2H202l-11.3-49.4h642.6z" fill="#D5D9CF"></path><path ' +
        'd="M826.4 836.7H197.6l-13.7-60.4h656.3l-13.8 60.4z m-620-11h611.' +
        '3l8.7-38.4H197.6l8.8 38.4z" fill="#333336"></path><path d="M758.' +
        '5 781.8h-493V667.1c0-19.7 16-35.7 35.7-35.7h421.6c19.7 0 35.7 16' +
        ' 35.7 35.7v114.7z" fill="#D5D9CF"></path><path d="M764 787.3H260' +
        'V667.1c0-22.7 18.5-41.2 41.2-41.2h421.6c22.7 0 41.2 18.5 41.2 41' +
        '.2v120.2z m-493-11h482V667.1c0-16.6-13.5-30.2-30.2-30.2H301.2c-1' +
        '6.6 0-30.2 13.5-30.2 30.2v109.2z" fill="#333336"></path><path d=' +
        '"M265.5 738h493v43.8h-493z" fill="#68A"></path><path d="M764 787' +
        '.3H260v-54.8h504v54.8z m-493-11h482v-32.8H271v32.8z" fill="#3333' +
        '36"></path><path d="M575.2 584.3V482.1c0-12.8 10.4-23.3 23.3-23.' +
        '3h220c12.8 0 23.3 10.4 23.3 23.3v102.1" fill="#FFD632"></path><p' +
        'ath d="M847.2 584.3h-11V482.1c0-9.8-8-17.8-17.8-17.8h-220c-9.8 0' +
        '-17.8 8-17.8 17.8v102.1h-11V482.1c0-15.9 12.9-28.8 28.8-28.8h220' +
        'c15.9 0 28.8 12.9 28.8 28.8v102.2z" fill="#333336"></path><path ' +
        'd="M145.1 578.8h730.6v11H145.1z" fill="#333336"></path><path d="' +
        'M784.5 523.1m-23 0a23 23 0 1 0 46 0 23 23 0 1 0-46 0Z" fill="#EC' +
        'EFE8"></path><path d="M784.5 550.1c-14.9 0-27-12.1-27-27s12.1-27' +
        ' 27-27 27 12.1 27 27-12.1 27-27 27z m0-46c-10.5 0-19 8.5-19 19s8' +
        '.5 19 19 19 19-8.5 19-19-8.5-19-19-19z" fill="#333336"></path><p' +
        'ath d="M627.7 545.8l-16.6-16.6c-3.6-3.6-3.6-9.4 0-13l16.6-16.6c5' +
        '.8-5.8 15.7-1.7 15.7 6.5v33.2c0 8.2-9.9 12.3-15.7 6.5z" fill="#E' +
        'CEFE8"></path><path d="M634.1 552.5c-3.4 0-6.7-1.3-9.3-3.9L608.2' +
        ' 532c-2.5-2.5-3.9-5.8-3.9-9.3 0-3.5 1.4-6.9 3.9-9.3l16.6-16.6c3.' +
        '9-3.9 9.4-5 14.4-2.9s8.2 6.8 8.2 12.2v33.2c0 5.4-3.1 10.1-8.2 12' +
        '.2-1.6 0.7-3.4 1-5.1 1z m0-51.7c-1.1 0-2.4 0.3-3.6 1.5L613.9 519' +
        'c-1 1-1.5 2.3-1.5 3.7 0 1.4 0.5 2.7 1.5 3.7l16.6 16.6c2.3 2.3 4.' +
        '9 1.4 5.7 1.1 0.8-0.3 3.2-1.6 3.2-4.8v-33.2c0-3.2-2.5-4.5-3.2-4.' +
        '8-0.4-0.2-1.1-0.5-2.1-0.5z" fill="#333336"></path><path d="M699 ' +
        '545.8l16.6-16.6c3.6-3.6 3.6-9.4 0-13L699 499.5c-5.8-5.8-15.7-1.7' +
        '-15.7 6.5v33.2c-0.1 8.3 9.8 12.4 15.7 6.6z" fill="#ECEFE8"></pat' +
        'h><path d="M692.5 552.5c-1.7 0-3.5-0.3-5.1-1-5-2.1-8.2-6.8-8.2-1' +
        '2.2v-33.2c0-5.4 3.1-10.1 8.2-12.2 5-2.1 10.6-1 14.4 2.9l16.6 16.' +
        '6c5.2 5.2 5.2 13.5 0 18.7l-16.6 16.6c-2.6 2.5-5.9 3.8-9.3 3.8z m' +
        '0-51.7c-1 0-1.7 0.3-2.1 0.4-0.8 0.3-3.2 1.6-3.2 4.8v33.2c0 3.2 2' +
        '.5 4.5 3.2 4.8 0.8 0.3 3.4 1.2 5.7-1.1l16.6-16.6c2-2 2-5.3 0-7.4' +
        'l-16.6-16.6c-1.2-1.1-2.5-1.5-3.6-1.5z" fill="#333336"></path></g' + '></svg>'
    end;

  SvgIconItem:= SVGIconImageCollectionPrinter.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'printer-default';
      SVGText:= '<svg viewBox="0 0 1024 1024" class="icon" version="1.1" xmlns="h' +
        'ttp://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarri' +
        'er" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-li' +
        'necap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCar' +
        'rier"><path d="M276.8 302.3h470.4v212.3H276.8z" fill="#FFD632"><' +
        '/path><path d="M752.7 520.1H271.3V296.8h481.4v223.3z m-470.4-11h' +
        '459.4V307.8H282.3v201.3z" fill="#333336"></path><path d="M363.8 ' +
        '192.8h296.5v271.6H363.8z" fill="#ECEFE8"></path><path d="M665.7 ' +
        '470H358.3V187.3h307.5V470z m-296.4-11h285.5V198.3H369.3V459z" fi' +
        'll="#333336"></path><path d="M842.7 781.8H181.3c-19.1 0-34.6-15.' +
        '5-34.6-34.6V460.9c0-19.1 15.5-34.6 34.6-34.6h661.4c19.1 0 34.6 1' +
        '5.5 34.6 34.6v286.3c0 19.1-15.5 34.6-34.6 34.6z" fill="#68A240">' +
        '</path><path d="M842.7 787.3H181.3c-22.1 0-40.1-18-40.1-40.1V460' +
        '.9c0-22.1 18-40.1 40.1-40.1h661.4c22.1 0 40.1 18 40.1 40.1v286.3' +
        'c0 22.1-18 40.1-40.1 40.1zM181.3 431.8c-16 0-29.1 13.1-29.1 29.1' +
        'v286.3c0 16 13.1 29.1 29.1 29.1h661.4c16 0 29.1-13.1 29.1-29.1V4' +
        '60.9c0-16-13.1-29.1-29.1-29.1H181.3z" fill="#333336"></path><pat' +
        'h d="M822 831.2H202l-11.3-49.4h642.6z" fill="#D5D9CF"></path><pa' +
        'th d="M826.4 836.7H197.6l-13.7-60.4h656.3l-13.8 60.4z m-620-11h6' +
        '11.3l8.7-38.4H197.6l8.8 38.4z" fill="#333336"></path><path d="M7' +
        '58.5 781.8h-493V667.1c0-19.7 16-35.7 35.7-35.7h421.6c19.7 0 35.7' +
        ' 16 35.7 35.7v114.7z" fill="#D5D9CF"></path><path d="M764 787.3H' +
        '260V667.1c0-22.7 18.5-41.2 41.2-41.2h421.6c22.7 0 41.2 18.5 41.2' +
        ' 41.2v120.2z m-493-11h482V667.1c0-16.6-13.5-30.2-30.2-30.2H301.2' +
        'c-16.6 0-30.2 13.5-30.2 30.2v109.2z" fill="#333336"></path><path' +
        ' d="M265.5 738h493v43.8h-493z" fill="#68A240"></path><path d="M7' +
        '64 787.3H260v-54.8h504v54.8z m-493-11h482v-32.8H271v32.8z" fill=' +
        '"#333336"></path><path d="M575.2 584.3V482.1c0-12.8 10.4-23.3 23' +
        '.3-23.3h220c12.8 0 23.3 10.4 23.3 23.3v102.1" fill="#FFD632"></p' +
        'ath><path d="M847.2 584.3h-11V482.1c0-9.8-8-17.8-17.8-17.8h-220c' +
        '-9.8 0-17.8 8-17.8 17.8v102.1h-11V482.1c0-15.9 12.9-28.8 28.8-28' +
        '.8h220c15.9 0 28.8 12.9 28.8 28.8v102.2z" fill="#333336"></path>' +
        '<path d="M145.1 578.8h730.6v11H145.1z" fill="#333336"></path><pa' +
        'th d="M784.5 523.1m-23 0a23 23 0 1 0 46 0 23 23 0 1 0-46 0Z" fil' +
        'l="#ECEFE8"></path><path d="M784.5 550.1c-14.9 0-27-12.1-27-27s1' +
        '2.1-27 27-27 27 12.1 27 27-12.1 27-27 27z m0-46c-10.5 0-19 8.5-1' +
        '9 19s8.5 19 19 19 19-8.5 19-19-8.5-19-19-19z" fill="#333336"></p' +
        'ath><path d="M627.7 545.8l-16.6-16.6c-3.6-3.6-3.6-9.4 0-13l16.6-' +
        '16.6c5.8-5.8 15.7-1.7 15.7 6.5v33.2c0 8.2-9.9 12.3-15.7 6.5z" fi' +
        'll="#ECEFE8"></path><path d="M634.1 552.5c-3.4 0-6.7-1.3-9.3-3.9' +
        'L608.2 532c-2.5-2.5-3.9-5.8-3.9-9.3 0-3.5 1.4-6.9 3.9-9.3l16.6-1' +
        '6.6c3.9-3.9 9.4-5 14.4-2.9s8.2 6.8 8.2 12.2v33.2c0 5.4-3.1 10.1-' +
        '8.2 12.2-1.6 0.7-3.4 1-5.1 1z m0-51.7c-1.1 0-2.4 0.3-3.6 1.5L613' +
        '.9 519c-1 1-1.5 2.3-1.5 3.7 0 1.4 0.5 2.7 1.5 3.7l16.6 16.6c2.3 ' +
        '2.3 4.9 1.4 5.7 1.1 0.8-0.3 3.2-1.6 3.2-4.8v-33.2c0-3.2-2.5-4.5-' +
        '3.2-4.8-0.4-0.2-1.1-0.5-2.1-0.5z" fill="#333336"></path><path d=' +
        '"M699 545.8l16.6-16.6c3.6-3.6 3.6-9.4 0-13L699 499.5c-5.8-5.8-15' +
        '.7-1.7-15.7 6.5v33.2c-0.1 8.3 9.8 12.4 15.7 6.6z" fill="#ECEFE8"' +
        '></path><path d="M692.5 552.5c-1.7 0-3.5-0.3-5.1-1-5-2.1-8.2-6.8' +
        '-8.2-12.2v-33.2c0-5.4 3.1-10.1 8.2-12.2 5-2.1 10.6-1 14.4 2.9l16' +
        '.6 16.6c5.2 5.2 5.2 13.5 0 18.7l-16.6 16.6c-2.6 2.5-5.9 3.8-9.3 ' +
        '3.8z m0-51.7c-1 0-1.7 0.3-2.1 0.4-0.8 0.3-3.2 1.6-3.2 4.8v33.2c0' +
        ' 3.2 2.5 4.5 3.2 4.8 0.8 0.3 3.4 1.2 5.7-1.1l16.6-16.6c2-2 2-5.3' +
        ' 0-7.4l-16.6-16.6c-1.2-1.1-2.5-1.5-3.6-1.5z" fill="#333336"></pa' + 'th></g></svg>'
    end;

  SvgIconItem:= SVGIconImageCollectionPrinter.SVGIconItems.Add;
  with SvgIconItem do
    begin
      IconName:= 'printer-offline';
      SVGText:= '<svg viewBox="0 0 1024 1024" class="icon" version="1.1" xmlns="h' +
        'ttp://www.w3.org/2000/svg" fill="#000000"><g id="SVGRepo_bgCarri' +
        'er" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-li' +
        'necap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCar' +
        'rier"><path d="M276.8 302.3h470.4v212.3H276.8z" fill="#FFD632"><' +
        '/path><path d="M752.7 520.1H271.3V296.8h481.4v223.3z m-470.4-11h' +
        '459.4V307.8H282.3v201.3z" fill="#333336"></path><path d="M363.8 ' +
        '192.8h296.5v271.6H363.8z" fill="#ECEFE8"></path><path d="M665.7 ' +
        '470H358.3V187.3h307.5V470z m-296.4-11h285.5V198.3H369.3V459z" fi' +
        'll="#333336"></path><path d="M842.7 781.8H181.3c-19.1 0-34.6-15.' +
        '5-34.6-34.6V460.9c0-19.1 15.5-34.6 34.6-34.6h661.4c19.1 0 34.6 1' +
        '5.5 34.6 34.6v286.3c0 19.1-15.5 34.6-34.6 34.6z" fill="#aaaaaa">' +
        '</path><path d="M842.7 787.3H181.3c-22.1 0-40.1-18-40.1-40.1V460' +
        '.9c0-22.1 18-40.1 40.1-40.1h661.4c22.1 0 40.1 18 40.1 40.1v286.3' +
        'c0 22.1-18 40.1-40.1 40.1zM181.3 431.8c-16 0-29.1 13.1-29.1 29.1' +
        'v286.3c0 16 13.1 29.1 29.1 29.1h661.4c16 0 29.1-13.1 29.1-29.1V4' +
        '60.9c0-16-13.1-29.1-29.1-29.1H181.3z" fill="#333336"></path><pat' +
        'h d="M822 831.2H202l-11.3-49.4h642.6z" fill="#D5D9CF"></path><pa' +
        'th d="M826.4 836.7H197.6l-13.7-60.4h656.3l-13.8 60.4z m-620-11h6' +
        '11.3l8.7-38.4H197.6l8.8 38.4z" fill="#333336"></path><path d="M7' +
        '58.5 781.8h-493V667.1c0-19.7 16-35.7 35.7-35.7h421.6c19.7 0 35.7' +
        ' 16 35.7 35.7v114.7z" fill="#D5D9CF"></path><path d="M764 787.3H' +
        '260V667.1c0-22.7 18.5-41.2 41.2-41.2h421.6c22.7 0 41.2 18.5 41.2' +
        ' 41.2v120.2z m-493-11h482V667.1c0-16.6-13.5-30.2-30.2-30.2H301.2' +
        'c-16.6 0-30.2 13.5-30.2 30.2v109.2z" fill="#333336"></path><path' +
        ' d="M265.5 738h493v43.8h-493z" fill="#aaaaaa"></path><path d="M7' +
        '64 787.3H260v-54.8h504v54.8z m-493-11h482v-32.8H271v32.8z" fill=' +
        '"#333336"></path><path d="M575.2 584.3V482.1c0-12.8 10.4-23.3 23' +
        '.3-23.3h220c12.8 0 23.3 10.4 23.3 23.3v102.1" fill="#FFD632"></p' +
        'ath><path d="M847.2 584.3h-11V482.1c0-9.8-8-17.8-17.8-17.8h-220c' +
        '-9.8 0-17.8 8-17.8 17.8v102.1h-11V482.1c0-15.9 12.9-28.8 28.8-28' +
        '.8h220c15.9 0 28.8 12.9 28.8 28.8v102.2z" fill="#333336"></path>' +
        '<path d="M145.1 578.8h730.6v11H145.1z" fill="#333336"></path><pa' +
        'th d="M784.5 523.1m-23 0a23 23 0 1 0 46 0 23 23 0 1 0-46 0Z" fil' +
        'l="#ECEFE8"></path><path d="M784.5 550.1c-14.9 0-27-12.1-27-27s1' +
        '2.1-27 27-27 27 12.1 27 27-12.1 27-27 27z m0-46c-10.5 0-19 8.5-1' +
        '9 19s8.5 19 19 19 19-8.5 19-19-8.5-19-19-19z" fill="#333336"></p' +
        'ath><path d="M627.7 545.8l-16.6-16.6c-3.6-3.6-3.6-9.4 0-13l16.6-' +
        '16.6c5.8-5.8 15.7-1.7 15.7 6.5v33.2c0 8.2-9.9 12.3-15.7 6.5z" fi' +
        'll="#ECEFE8"></path><path d="M634.1 552.5c-3.4 0-6.7-1.3-9.3-3.9' +
        'L608.2 532c-2.5-2.5-3.9-5.8-3.9-9.3 0-3.5 1.4-6.9 3.9-9.3l16.6-1' +
        '6.6c3.9-3.9 9.4-5 14.4-2.9s8.2 6.8 8.2 12.2v33.2c0 5.4-3.1 10.1-' +
        '8.2 12.2-1.6 0.7-3.4 1-5.1 1z m0-51.7c-1.1 0-2.4 0.3-3.6 1.5L613' +
        '.9 519c-1 1-1.5 2.3-1.5 3.7 0 1.4 0.5 2.7 1.5 3.7l16.6 16.6c2.3 ' +
        '2.3 4.9 1.4 5.7 1.1 0.8-0.3 3.2-1.6 3.2-4.8v-33.2c0-3.2-2.5-4.5-' +
        '3.2-4.8-0.4-0.2-1.1-0.5-2.1-0.5z" fill="#333336"></path><path d=' +
        '"M699 545.8l16.6-16.6c3.6-3.6 3.6-9.4 0-13L699 499.5c-5.8-5.8-15' +
        '.7-1.7-15.7 6.5v33.2c-0.1 8.3 9.8 12.4 15.7 6.6z" fill="#ECEFE8"' +
        '></path><path d="M692.5 552.5c-1.7 0-3.5-0.3-5.1-1-5-2.1-8.2-6.8' +
        '-8.2-12.2v-33.2c0-5.4 3.1-10.1 8.2-12.2 5-2.1 10.6-1 14.4 2.9l16' +
        '.6 16.6c5.2 5.2 5.2 13.5 0 18.7l-16.6 16.6c-2.6 2.5-5.9 3.8-9.3 ' +
        '3.8z m0-51.7c-1 0-1.7 0.3-2.1 0.4-0.8 0.3-3.2 1.6-3.2 4.8v33.2c0' +
        ' 3.2 2.5 4.5 3.2 4.8 0.8 0.3 3.4 1.2 5.7-1.1l16.6-16.6c2-2 2-5.3' +
        ' 0-7.4l-16.6-16.6c-1.2-1.1-2.5-1.5-3.6-1.5z" fill="#333336"></pa' + 'th></g></svg>'
    end;

  // Link the collection to an image list
  SVGIconVirtualImageList:= TSVGIconVirtualImageList.Create(nil);
  SVGIconVirtualImageList.Height:= MulDiv(48, Screen.PixelsPerInch, 240);
  SVGIconVirtualImageList.Width:= MulDiv(48, Screen.PixelsPerInch, 240);
  SVGIconVirtualImageList.ImageCollection:= SVGIconImageCollection;
  SVGIconVirtualImageList.Add('actions-caret-bar-left', 'actions-caret-bar-left');
  SVGIconVirtualImageList.Add('actions-caret-bar-right', 'actions-caret-bar-right');
  SVGIconVirtualImageList.Add('actions-caret-left', 'actions-caret-left');
  SVGIconVirtualImageList.Add('actions-caret-right', 'actions-caret-right');
  SVGIconVirtualImageList.Add('zoom-in', 'zoom-in');
  SVGIconVirtualImageList.Add('zoom-out', 'zoom-out');
  SVGIconVirtualImageList.Add('component-divider-vertical', 'component-divider-vertical');
  SVGIconVirtualImageList.Add('print-outline', 'print-outline');
  SVGIconVirtualImageList.Add('find-filled', 'find-filled');
  SVGIconVirtualImageList.Add('save', 'save');
  SVGIconVirtualImageList.Add('close-light', 'close-light');

  SVGIconVirtualImageListPrinter:= TSVGIconVirtualImageList.Create(nil);
  SVGIconVirtualImageListPrinter.Height:= MulDiv(96, Screen.PixelsPerInch, 240);
  SVGIconVirtualImageListPrinter.Width:= MulDiv(96, Screen.PixelsPerInch, 240);
  SVGIconVirtualImageListPrinter.ImageCollection:= SVGIconImageCollectionPrinter;
  SVGIconVirtualImageListPrinter.Add('printer-storing', 'printer-storing');
  SVGIconVirtualImageListPrinter.Add('printer-beschikbaar', 'printer-beschikbaar');
  SVGIconVirtualImageListPrinter.Add('printer-default', 'printer-default');
  SVGIconVirtualImageListPrinter.Add('printer-offline', 'printer-offline');
end;

function TRLPreviewForm.InitSpeedButton(AName: string; ALeft, AWidth: Integer; ACaption: string; AImage: string;
  AOnClick: TNotifyEvent): TSpeedButton;
begin
  Result:= TSpeedButton.Create(Self);
  with Result do
    begin
      name:= AName;
      Parent:= PanelTools;
      Left:= ALeft; // Already High DPI aware
      Top:= 1;
      Width:= AWidth; // Already High DPI aware
      Height:= ToolBarHeight; // Already High DPI aware
      Margins.Left:= MulDiv(4, Screen.PixelsPerInch, 144);
      Margins.Top:= MulDiv(4, Screen.PixelsPerInch, 144);
      Margins.Right:= MulDiv(4, Screen.PixelsPerInch, 144);
      Margins.Bottom:= MulDiv(4, Screen.PixelsPerInch, 144);
      Caption:= ACaption;
      Flat:= True;
      StyleName:= 'Windows';
      OnClick:= AOnClick;
      Images:= SVGIconVirtualImageList;
      ImageName:= AImage;
    end;
end;

function TRLPreviewForm.InitPanel(AParent: TWinControl; AName: string; ALeft, AWidth: Integer; ACaption: string;
  AAlign: TAlign): TPanel;
begin
  Result:= TPanel.Create(PanelTools);
  with Result do
    begin
      name:= AName;
      Parent:= AParent;
      Left:= ALeft; // Already High DPI aware
      Top:= MulDiv(0, Screen.PixelsPerInch, 144);
      Width:= MulDiv(AWidth, Screen.PixelsPerInch, 144);
      Height:= ToolBarHeight; // Already High DPI aware
      Caption:= ACaption;
      Align:= AAlign;
      BevelOuter:= bvNone;
      BevelInner:= bvNone;
      BevelKind:= bkNone;
    end;
end;

function TRLPreviewForm.InitLabel(ATop: Integer; ACaption: string): TLabel;
begin
  Result:= TLabel.Create(PanelLeft);
  with Result do
    begin
      Parent:= PanelLeft;
      Left:= MulDiv(58, Screen.PixelsPerInch, 240);
      Top:= MulDiv(ATop, Screen.PixelsPerInch, 240);
      Width:= MulDiv(115, Screen.PixelsPerInch, 240);
      Height:= ToolBarHeight; // Already High DPI aware
      Caption:= ACaption;
      Font.Charset:= DEFAULT_CHARSET;
      Font.Color:= clWindowText;
      Font.Height:= MulDiv(-30, Screen.PixelsPerInch, 240);
      Font.Name:= 'Segoe UI';
      Font.Pitch:= fpVariable;
      Font.Style:= [fsBold];
      ParentFont:= False;
    end;
end;

function TRLPreviewForm.InitRadioGroup(ATop, Aheight: Integer): TRadioGroup;
begin
  Result:= TRadioGroup.Create(PanelLeft);
  with Result do
    begin
      Parent:= PanelLeft;
      Left:= MulDiv(58, Screen.PixelsPerInch, 240);
      Top:= MulDiv(ATop, Screen.PixelsPerInch, 240);
      Width:= MulDiv(463, Screen.PixelsPerInch, 240);
      Height:= MulDiv(Aheight, Screen.PixelsPerInch, 144);
      Font.Charset:= DEFAULT_CHARSET;
      Font.Color:= clWindowText;
      Font.Height:= MulDiv(-30, Screen.PixelsPerInch, 240);
      Font.Name:= 'Segoe UI';
      Font.Pitch:= fpVariable;
      Font.Style:= [];
      ItemIndex:= 0;
      ParentFont:= False;
      ShowFrame:= False;
      TabOrder:= 4;
    end;
end;

procedure TRLPreviewForm.Init;
begin
  InitIcons(SVGIconVirtualImageList);

  Name:= 'frmPreview';
  LoadConfig; // Load settings from Registry (TLForm)
  Caption:= 'Report Preview';
  Color:= clWindow;
  OnShow:= FormShow;

  { Panel Left ============================================================================== }
  // Printer settings

  PanelLeft:= InitPanel(Self, 'LeftPanel', 0, 493, '', alLeft);

  ComboBoxPrinter:= TComboBoxEx.Create(PanelLeft);
  with ComboBoxPrinter do
    begin
      Parent:= PanelLeft;
      name:= 'ComboBoxExPrinter';
      Left:= MulDiv(58, Screen.PixelsPerInch, 240);
      Top:= MulDiv(80, Screen.PixelsPerInch, 240);
      Width:= MulDiv(700, Screen.PixelsPerInch, 240);
      Items.Assign(Printer.Printers);
      ItemIndex:= Printer.PrinterIndex;
      ItemHeight:= MulDiv(88, Screen.PixelsPerInch, 240);
      TabOrder:= 0;
      Images:= SVGIconVirtualImageListPrinter;
      OnChange:= ComboBoxPrinterChange;
    end;
  for var I:= 0 to ComboBoxPrinter.ItemsEx.Count - 1 do
    begin
      ComboBoxPrinter.ItemsEx[I].ImageIndex:= 1;
    end;
  ComboBoxPrinter.ItemsEx[ComboBoxPrinter.ItemIndex].ImageIndex:= 2;
  ComboBoxPrinter.ItemsEx[0].ImageIndex:= 1; // 0 nog een keer anders pakt ie het icon niet????

  ComboBoxDuplex:= TComboBox.Create(PanelLeft);
  with ComboBoxDuplex do
    begin
      Parent:= PanelLeft;
      name:= 'ComboBoxDuplex';
      Left:= MulDiv(58, Screen.PixelsPerInch, 240);
      Top:= MulDiv(1077, Screen.PixelsPerInch, 240);
      Width:= MulDiv(700, Screen.PixelsPerInch, 240);
      Height:= MulDiv(49, Screen.PixelsPerInch, 240);
      ItemIndex:= 0;
      TabOrder:= 0;
      ItemHeight:= MulDiv(96, Screen.PixelsPerInch, 240);
      Items.Add('Enkelzijdig afdrukken;Afdrukken op slechts één zijde van de pagina');
      Items.Add('Dubbelzijdig afdrukken;Over lange zijde omslaan');
      Items.Add('Dubbelzijdig afdrukken;Over korte zijde omslaan');
      ItemIndex:= 0;
      Style:= csOwnerDrawFixed;
      OnDrawItem:= ComboBoxDuplexDrawItem;
      OnChange:= ComboBoxDuplexChange;
      Enabled:= RLPrinter.SupportsDuplex;
    end;

  Label1:= InitLabel(200, 'Kopie'#235'n');
  Label2:= InitLabel(360, 'Indeling');
  Label3:= InitLabel(617, 'Pagina'#39's');
  Label5:= InitLabel(1020, 'Dubbelzijdig afdrukken');
  Label6:= InitLabel(23, 'Printer');

  ButtonAnnuleren:= TButton.Create(PanelLeft);
  with ButtonAnnuleren do
    begin
      Parent:= PanelLeft;
      Left:= MulDiv(440, Screen.PixelsPerInch, 240);
      Top:= MulDiv(1260, Screen.PixelsPerInch, 240);
      Width:= MulDiv(318, Screen.PixelsPerInch, 240);
      Height:= MulDiv(63, Screen.PixelsPerInch, 240);
      Caption:= 'Annuleren';
      TabOrder:= 2;
      OnClick:= ButtonAnnulerenClick;
    end;

  ButtonAfdrukken:= TButton.Create(PanelLeft);
  with ButtonAfdrukken do
    begin
      Parent:= PanelLeft;
      Left:= MulDiv(58, Screen.PixelsPerInch, 240);
      Top:= MulDiv(1260, Screen.PixelsPerInch, 240);
      Width:= MulDiv(318, Screen.PixelsPerInch, 240);
      Height:= MulDiv(63, Screen.PixelsPerInch, 240);
      Caption:= 'Afdrukken';
      TabOrder:= 1;
      // default:= True;
      OnClick:= SpeedButtonAfdrukkenClick;
    end;

  SpinEditCopies:= TSpinEdit.Create(PanelLeft);
  with SpinEditCopies do
    begin
      Parent:= PanelLeft;
      Left:= MulDiv(58, Screen.PixelsPerInch, 240);
      Top:= MulDiv(257, Screen.PixelsPerInch, 240);
      Width:= MulDiv(221, Screen.PixelsPerInch, 240);
      Height:= MulDiv(49, Screen.PixelsPerInch, 240);
      TabOrder:= 3;
      MinValue:= 1;
      MaxValue:= 99;
      Value:= 1;
      RLPrinter.Copies:= StrToInt(Text);
      OnChange:= SpinEditCopiesChange;
    end;

  RadioGroupLayout:= InitRadioGroup(360, 121);
  with RadioGroupLayout do
    begin
      Items.Add('  Staand');
      Items.Add('  Liggend');
    end;

  RadioGroupPages:= InitRadioGroup(617, 207);
  with RadioGroupPages do
    begin
      Items.Add('  Alle');
      Items.Add('  Alleen oneven pagina'#39's');
      Items.Add('  Alleen even pagina'#39's');
      Items.Add('');
    end;
  RadioGroupPages.ItemIndex:= 0;

  EditPageSelection:= TEdit.Create(PanelLeft);
  with EditPageSelection do
    begin
      Parent:= PanelLeft;
      Left:= MulDiv(125, Screen.PixelsPerInch, 240);
      Top:= MulDiv(897, Screen.PixelsPerInch, 240);
      Width:= MulDiv(633, Screen.PixelsPerInch, 240);
      TabOrder:= 6;
      TextHint:= 'bijv. 1-5, 8, 11-13';
      Text:= '';
      OnChange:= EditPageSelectionChange;
    end;

  { Panel Right ============================================================================== }
  // Preview container with attached ToolBar

  PanelRight:= InitPanel(Self, 'RightPanel', 401, 500, '', alClient);

  { Preview container }
  PanelContainer:= InitPanel(PanelRight, 'PanelContainer', 0, 807, '', alClient);
  PanelContainer.BevelOuter:= bvNone;

  { Toolbar }

  ToolBarHeight:= MulDiv(56, Screen.PixelsPerInch, 144);
  SpeedButtonWidth:= MulDiv(56, Screen.PixelsPerInch, 144);
  var
  SpeedButtonExWidth:= MulDiv(48, Screen.PixelsPerInch, 144); // For smaller arrow buttons

  // Attach Toolbar at the bottom
  PanelTools:= InitPanel(PanelRight, 'PanelTools', 401, 0, '', alBottom);

  // tbv centreren Toolbar onder het preview document
  with PanelTools do
    begin
      AlignWithMargins:= True;
      Margins.Top:= 0;
      Margins.Bottom:= 0;
      Margins.Left:= 0;
      Margins.Right:= 0;
    end;

  SpeedButtonFirst:= InitSpeedButton('SpeedButtonFirst', 0, SpeedButtonExWidth, '', 'actions-caret-bar-left',
    SpeedButtonFirstClick);
  SpeedButtonPrior:= InitSpeedButton('SpeedButtonPrior', SpeedButtonFirst.Left + SpeedButtonFirst.Width,
    SpeedButtonExWidth, '', 'actions-caret-left', SpeedButtonPriorClick);

  PanelPage:= InitPanel(PanelTools, 'PanelPage', SpeedButtonPrior.Left + SpeedButtonPrior.Width, 0, 'Page', alNone);
  PanelPage.Top:= 0;

  PanelEditPageNo:= InitPanel(PanelTools, 'PanelEditPageNo', PanelPage.Left + PanelPage.Width, 48, '', alNone);
  with PanelEditPageNo do
    begin
      Parent:= PanelTools;
    end;

  EditPageNo:= TEdit.Create(PanelEditPageNo);
  with EditPageNo do
    begin
      Parent:= PanelEditPageNo;
      name:= 'EditPageNo';
      Left:= 0;
      Top:= 0;
      Width:= 70;
      AlignWithMargins:= True;
      Margins.Left:= 0;
      Margins.Top:= MulDiv(15, Screen.PixelsPerInch, 144);
      Margins.Right:= 0;
      Margins.Bottom:= MulDiv(15, Screen.PixelsPerInch, 144);
      Align:= alClient;
      TabOrder:= 0;
      Text:= '';
      OnChange:= EditPageNoChange;
    end;

  PanelOf:= InitPanel(PanelTools, 'PanelOf', PanelEditPageNo.Left + PanelEditPageNo.Width, 48, '/', alNone);
  PanelPageCount:= InitPanel(PanelTools, 'PanelPageCount', PanelOf.Left + PanelOf.Width, 32, '999', alNone);
  PanelPageCount.Alignment:= taLeftJustify;

  SpeedButtonNext:= InitSpeedButton('SpeedButtonNext', PanelPageCount.Left + PanelPageCount.Width, SpeedButtonExWidth, '',
    'actions-caret-right', SpeedButtonNextClick);
  SpeedButtonLast:= InitSpeedButton('SpeedButtonLast', SpeedButtonNext.Left + SpeedButtonNext.Width, SpeedButtonExWidth,
    '', 'actions-caret-bar-right', SpeedButtonLastClick);

  PanelComboBoxZoom:= InitPanel(PanelTools, 'PanelComboBoxZoom', SpeedButtonLast.Left + SpeedButtonLast.Width, 250,
    '', alNone);
  PanelComboBoxZoom.BorderWidth:= MulDiv(6, Screen.PixelsPerInch, 240);
  ComboBoxZoom:= TComboBox.Create(PanelComboBoxZoom);
  with ComboBoxZoom do
    begin
      name:= 'ComboBoxZoom';
      Parent:= PanelComboBoxZoom;
      BevelKind:= bkNone;
      AlignWithMargins:= True;
      Margins.Left:= MulDiv(72, Screen.PixelsPerInch, 144);
      Margins.Top:= MulDiv(12, Screen.PixelsPerInch, 144);
      Margins.Right:= MulDiv(0, Screen.PixelsPerInch, 144);
      Align:= alClient;
      TabOrder:= 0;
      DropDownCount:= 11;
      TabOrder:= 0;
      Items.Text:= '500%' + sLineBreak + '200%' + sLineBreak + '150%' + sLineBreak + '100%' + sLineBreak + '75%' +
        sLineBreak + '50%' + sLineBreak + '25%' + sLineBreak + '10%' + sLineBreak + 'Paginabreedte' + sLineBreak +
        'Volledige pagina' + sLineBreak + 'Meerdere pagina''s' + sLineBreak;
      OnChange:= ComboBoxZoomChange;
    end;

  SpeedButtonZoomDown:= InitSpeedButton('SpeedButtonZoomDown', PanelComboBoxZoom.Left + PanelComboBoxZoom.Width,
    SpeedButtonWidth, '', 'zoom-out', SpeedButtonZoomDownClick);
  SpeedButtonZoomUp:= InitSpeedButton('SpeedButtonZoomUp', SpeedButtonZoomDown.Left + SpeedButtonWidth,
    SpeedButtonWidth, '', 'zoom-in', SpeedButtonZoomUpClick);
  SpeedButtonViews:= InitSpeedButton('SpeedButtonViews', SpeedButtonZoomUp.Left + SpeedButtonWidth, SpeedButtonWidth,
    '', 'component-divider-vertical', SpeedButtonViewsClick);
  SpeedButtonSearch:= InitSpeedButton('SpeedButtonSearch', SpeedButtonViews.Left + SpeedButtonWidth, SpeedButtonWidth,
    '', 'find-filled', SpeedButtonSearchClick);

  ToolbarWidth:= SpeedButtonSearch.Left + SpeedButtonWidth;

  // Prevent Left Toolbar from hiding
  Constraints.MinHeight:= ButtonAfdrukken.Top + 2 * ButtonAfdrukken.Height + MulDiv(64, Screen.PixelsPerInch, 144);
  // Prevent Toolbar from hiding
  Constraints.MinWidth:= PanelLeft.Width + ToolbarWidth + MulDiv(64, Screen.PixelsPerInch, 144);
  // Keep toolbar centered below preview document
  OnResize:= FormResize;
end;

procedure TRLPreviewForm.OnClickRLAbout(Sender: TObject);
var
  LFormRLAbout: TFormRLAbout;
begin
  LFormRLAbout:= TFormRLAbout.Create(Self);
  try
    LFormRLAbout.ShowModal;
  finally
    LFormRLAbout.Free;
  end;
end;

procedure TRLPreviewForm.DoClose(var Action: TCloseAction);
begin
  DefaultWindowState:= WindowState;
  DefaultWindowBounds:= BoundsRect;
  Action:= caFree;
end;

procedure TRLPreviewForm.ComboBoxDuplexChange(Sender: TObject);
var
  Device, Driver, Port: string;
  DriverHandle: THandle;
  DevModeRef: PDeviceMode;
begin
  Printer.GetPrinter(Device, Driver, Port, DriverHandle);
  if DriverHandle <> 0 then
    begin
      DevModeRef:= GlobalLock(DriverHandle);
      if DevModeRef <> nil then
        try
          case ComboBoxDuplex.ItemIndex of
            0:
              begin

                DevModeRef^.dmDuplex:= DMDUP_SIMPLEX; // Simplex
                DevModeRef^.dmFields:= DevModeRef^.dmFields and not DWORD(DM_DUPLEX);
              end;
            1:
              begin

                DevModeRef^.dmDuplex:= DMDUP_VERTICAL; // Duplex lange zijde
                DevModeRef^.dmFields:= DevModeRef^.dmFields or DM_DUPLEX;
              end;
            2:
              begin
                DevModeRef^.dmDuplex:= DMDUP_HORIZONTAL; // Duplex Korte zijde
                DevModeRef^.dmFields:= DevModeRef^.dmFields or DM_DUPLEX;
              end;
          end;
        finally
          GlobalUnlock(DriverHandle);
        end;
    end;
  Printer.SetPrinter(Device, Driver, Port, DriverHandle);
end;

procedure TRLPreviewForm.ComboBoxDuplexDrawItem(Control: TWinControl; Index: Integer; Rect: TRect;
  State: TOwnerDrawState);
var
  TextLine1, TextLine2: string;
  TextHeight: Integer;
  DrawRect: TRect;
  Delimiter: string;
  ResultArray: TArray<string>;
begin
  with Control as TComboBox do
    begin
      Canvas.FillRect(Rect); // Clear the background

      // Items comprising two lines 'Line 1;Line 2'
      // First line printed bold, Second line printed normal and a slightly smaller fontsize

      // Split the string
      Delimiter:= ';';
      ResultArray:= SplitString(Items[index], Delimiter);

      // Define two lines of text for each item
      TextLine1:= ResultArray[0]; // First line
      TextLine2:= ResultArray[1]; // Second line

      // Calculate the height of each text line
      TextHeight:= Canvas.TextHeight(TextLine1);

      // Draw the first line
      DrawRect:= Rect;
      DrawRect.Top:= Rect.Top + 2; // Add padding
      DrawRect.Left:= Rect.Left + 11;
      Canvas.Font.Style:= [fsBold];
      Canvas.TextOut(DrawRect.Left + 2, DrawRect.Top, TextLine1);

      // Draw the second line below the first
      DrawRect.Top:= DrawRect.Top + TextHeight + 2; // Adjust for line height
      Canvas.Font.Style:= [];
      Canvas.Font.Size:= 8;
      Canvas.TextOut(DrawRect.Left + 2, DrawRect.Top, TextLine2);
    end;
end;

procedure TRLPreviewForm.ComboBoxPrinterChange(Sender: TObject);
begin
  with Sender as TComboBoxEx do
    begin
      if Printer.PrinterIndex = ItemIndex then
        begin
          printCommand:= 'print';
          printerInfo:= '';
        end
      else
        begin
          printCommand:= 'printto';
          Printer.PrinterIndex:= ItemIndex;
          Printer.GetPrinter(Device, Driver, Port, hDeviceMode);
          printerInfo:= Format('"%s" "%s" "%s"', [Device, Driver, Port]);
        end;
      // ShellExecute(Application.Handle, PChar(printCommand), PChar(documentToPrint), PChar(printerInfo), nil, SW_HIDE) ;
    end;
  if Assigned(ComboBoxDuplex) then
    ComboBoxDuplex.Enabled:= RLPrinter.SupportsDuplex;
  if Assigned(Label5) then
    Label5.Enabled:= RLPrinter.SupportsDuplex;
end;

procedure TRLPreviewForm.ComboBoxZoomChange(Sender: TObject);
var
  Z: Double;
  I, E: Integer;
begin
  FEditingZoom:= True;
  try
    I:= ComboBoxZoom.Items.IndexOf(ComboBoxZoom.Text);
    if I <> -1 then
      Z:= 0
    else
      begin
        Val(StringReplace(StringReplace(ComboBoxZoom.Text, '%', '', []), ',', '.', []), Z, E);
        if E <> 0 then
          Z:= 0;
        I:= ComboBoxZoom.ItemIndex;
      end;
    if Z >= 10 then
      Preview.ZoomFactor:= Z
    else
      case I of
        0:
          Preview.ZoomFactor:= 500;
        1:
          Preview.ZoomFactor:= 200;
        2:
          Preview.ZoomFactor:= 150;
        3:
          Preview.ZoomFactor:= 100;
        4:
          Preview.ZoomFactor:= 75;
        5:
          Preview.ZoomFactor:= 50;
        6:
          Preview.ZoomFactor:= 25;
        7:
          Preview.ZoomFactor:= 10;
        8:
          Preview.ZoomFullWidth;
        9:
          Preview.ZoomFullPage;
        10:
          Preview.ZoomMultiplePages;
      end;
  finally
    FEditingZoom:= False;
  end;
end;

procedure TRLPreviewForm.EditPageSelectionChange(Sender: TObject);
begin
  if (Sender as TEdit).Text <> '' then
    RadioGroupPages.ItemIndex:= 3;
end;

procedure TRLPreviewForm.EditPageNoChange(Sender: TObject);
begin
  FEditingPageNo:= True;
  try
    Preview.PageIndex:= StrToIntDef(EditPageNo.Text, Preview.PageIndex) - 1;
  finally
    FEditingPageNo:= False;
  end;
end;

procedure TRLPreviewForm.SpeedButtonAfdrukkenClick(Sender: TObject);
var
  priorfocus: TWinControl;
  firstpg: Integer;
  lastpg: Integer;
  selection: string;
  oddp: Integer;
  Prn: TRLCustomFilter;

begin
  priorfocus:= Screen.ActiveControl;
  try
    selection:= '';
    oddp:= PrintOddAndEvenPages;
    case RadioGroupPages.ItemIndex of
      1:
        oddp:= PrintOddPagesOnly;
      2:
        oddp:= PrintEvenPagesOnly;
      3:
        selection:= EditPageSelection.Text;
    end;
    firstpg:= 1;
    lastpg:= Preview.Pages.PageCount;

    Prn:= SpoolFilter;
    Prn.ClassOptions:=  Prn.ClassOptions - [foEmulateCopies];

    FilterPages(Preview.Pages, Prn {nil}, firstpg, lastpg, selection, oddp);
    SentToPrinter:= True;
  finally
    // focuscontrole voor CLX
    if not Assigned(priorfocus) or not((priorfocus is TCustomEdit) or (priorfocus is TCustomComboBox)) then
      priorfocus:= EditPageNo;
    priorfocus.SetFocus;
  end;
  if Assigned(SetupInstance) and Assigned(SetupInstance.AfterPrint) then
    SetupInstance.AfterPrint(Self);
end;

procedure TRLPreviewForm.SpeedButtonFirstClick(Sender: TObject);
begin
  Preview.FirstPage;
end;

procedure TRLPreviewForm.SpeedButtonLastClick(Sender: TObject);
begin
  Preview.LastPage;
end;

procedure TRLPreviewForm.SpeedButtonNextClick(Sender: TObject);
begin
  Preview.NextPage;
end;

function FileNameFromText(const AText: string): string;
var
  I: Integer;
begin
  Result:= Trim(AText);
  for I:= Length(Result) downto 1 do
    if CharInSet(Result[I], [#0 .. #31, #127, '?', '*', ':', '/', '\', '>', '<', '|', '"', '.']) then
      Delete(Result, I, 1);
end;

procedure TRLPreviewForm.SpeedButtonSaveClick(Sender: TObject);
var
  priorfocus: TWinControl;
  filt: TRLCustomSaveFilter;
  fname: string;
  fext: string;
  firstpg: Integer;
  lastpg: Integer;
begin
  if Assigned(SetupInstance) and Assigned(SetupInstance.BeforeSave) then
    SetupInstance.BeforeSave(Self);
  priorfocus:= Screen.ActiveControl;
  try
    with TRLSaveDialog.CreateNew(nil) do
      try
        MaxPage:= Preview.Pages.PageCount;
        filt:= nil;
        if (SelectedFilter <> nil) and (SelectedFilter is TRLCustomSaveFilter) then
          filt:= TRLCustomSaveFilter(SelectedFilter);

        if Self.Preview.Pages.Title <> '' then
          FileName:= ExpandFileName(FileNameFromText(Self.Preview.Pages.Title))
        else if (filt <> nil) then
          FileName:= filt.FileName
        else
          FileName:= '';

        if not Execute then
          exit;

        if (FileName = '') then
          raise Exception.Create(GetLocalizeStr(LocaleStrings.LS_FileNameIsEmpty));

        firstpg:= FromPage;
        lastpg:= ToPage;
        fname:= FileName;
        fext:= ExtractFileExt(fname);
        if fext = '' then
          begin
            ApplyExt(fname);
            fext:= ExtractFileExt(fname);
          end;

        if (filt = nil) or (LowerCase(filt.DefaultExt) <> LowerCase(fext)) then
          filt:= SaveFilterByFileName(fname);

        if filt <> nil then
          begin
            filt.FileName:= fname;
            filt.FilterPages(Preview.Pages, firstpg, lastpg, '', PrintOddAndEvenPages);
          end
        else
          Preview.Pages.SaveToFile(fname);
      finally
        Free;
      end;
  finally
    // focuscontrole voor CLX
    if not Assigned(priorfocus) or not((priorfocus is TCustomEdit) or (priorfocus is TCustomComboBox)) then
      priorfocus:= EditPageNo;
    priorfocus.SetFocus;
  end;
  if Assigned(SetupInstance) and Assigned(SetupInstance.AfterSave) then
    SetupInstance.AfterSave(Self);
end;

procedure TRLPreviewForm.SpeedButtonSendClick(Sender: TObject);
begin
  if Assigned(SetupInstance) and Assigned(SetupInstance.BeforeSend) then
    SetupInstance.BeforeSend(Self);
  if Assigned(SetupInstance) and Assigned(SetupInstance.OnSend) then
    SetupInstance.OnSend(Self);
  if Assigned(SetupInstance) and Assigned(SetupInstance.AfterSend) then
    SetupInstance.AfterSend(Self);
end;

procedure TRLPreviewForm.SpeedButtonSearchClick(Sender: TObject);
begin
  ShowFindDialog;
end;

procedure TRLPreviewForm.ShowFindDialog;
begin
  if not Assigned(FFindDialog) then
    begin
      FFindDialog:= TfrmRLFindDialog.CreateNew(nil);
      FFindDialog.OnFind:= OnFindHandler;
    end;
  FFindDialog.ActiveControl:= FFindDialog.EditTextToFind;
  FFindDialog.Show;
end;

procedure TRLPreviewForm.OnFindHandler(Sender: TObject; const AText: string; Options: TRLFindOptions;
  var Found: Boolean);
begin
  Found:= Preview.FindText(AText, foWholeWords in Options, foMatchCase in Options, foFindBackward in Options);
end;

procedure TRLPreviewForm.UpdateComboBoxZoom;
var
  savedevent: TNotifyEvent;
begin
  if FEditingZoom then
    exit;
  savedevent:= ComboBoxZoom.OnChange;
  try
    ComboBoxZoom.ItemIndex:= -1;
    ComboBoxZoom.Text:= FloatToStr(Preview.ZoomFactor) + '%';
  finally
    ComboBoxZoom.OnChange:= savedevent;
  end;
end;

procedure TRLPreviewForm.UpdateEditPageNo;
var
  savedevent: TNotifyEvent;
begin
  if FEditingPageNo then
    exit;
  savedevent:= EditPageNo.OnChange;
  try
    EditPageNo.Text:= IntToStr(Preview.PageIndex + 1);
  finally
    EditPageNo.OnChange:= savedevent;
  end;
end;

procedure TRLPreviewForm.rpvDefaultChangeView(Sender: TObject);
begin
  PanelPageCount.Caption:= IntToStr(Preview.Pages.PageCount);
  UpdateEditPageNo;
  UpdateComboBoxZoom;
end;

procedure TRLPreviewForm.SpeedButtonPriorClick(Sender: TObject);
begin
  Preview.PriorPage;
end;

procedure TRLPreviewForm.SpeedButtonZoomUpClick(Sender: TObject);
begin
  Preview.ZoomFactor:= Preview.ZoomFactor + 10;
  UpdateComboBoxZoom;
end;

procedure TRLPreviewForm.SpinEditCopiesChange(Sender: TObject);
begin
   RLPrinter.Copies:= SpinEditCopies.Value;
end;

procedure TRLPreviewForm.SpeedButtonZoomDownClick(Sender: TObject);
begin
  Preview.ZoomFactor:= Max(10, Preview.ZoomFactor - 10);
  UpdateComboBoxZoom;
end;

procedure TRLPreviewForm.SpeedButtonViewsClick(Sender: TObject);
begin
  if FPreviewList.Count > 1 then
    ReleasePreview
  else
    NewPreview;
  OrganizePreviews;
end;

procedure TRLPreviewForm.SpeedButtonEditClick(Sender: TObject);
begin
  Preview.Editing:= not Preview.Editing;
end;

function TRLPreviewForm.GetPreview: TRLPreview;
begin
  Result:= TRLPreview(FPreviewList[FPreviewIndex]);
end;

procedure TRLPreviewForm.PreviewEnter(Sender: TObject);
begin
  SetPreview(TRLPreview(Sender));
end;

procedure TRLPreviewForm.SetPreview(APreview: TRLPreview);
begin
  FPreviewIndex:= FPreviewList.IndexOf(APreview);
  UpdateEditPageNo;
  UpdateComboBoxZoom;
end;

{ TRLPreviewSetup }

constructor TRLPreviewSetup.Create(AOwner: TComponent);
begin
  FBeforePrint:= nil;
  FAfterPrint:= nil;
  FBeforeSave:= nil;
  FAfterSave:= nil;
  FBeforeSend:= nil;
  FOnSend:= nil;
  FAfterSend:= nil;
  FEnabledButtons:= [pbPrint, pbSave, pbSend];
  FEditOptions:= [];
  FCustomActionText:= '';
  FOnCustomAction:= nil;
  inherited;
  if not(csDesigning in ComponentState) then
    begin
      if Assigned(SetupInstance) then
        raise Exception.Create(Format(GetLocalizeStr(LocaleStrings.LS_OnlyOneInstance), [ClassName]));
      SetupInstance:= Self;
    end;
end;

destructor TRLPreviewSetup.Destroy;
begin
  if SetupInstance = Self then
    SetupInstance:= nil;
  inherited;
end;

function TRLPreviewSetup.GetBorderIcons: TBorderIcons;
begin
  Result:= DefaultBorderIcons;
end;

function TRLPreviewSetup.GetCaption: string;
begin
  Result:= DefaultCaption;
end;

function TRLPreviewSetup.GetFormStyle: TFormStyle;
begin
  Result:= DefaultFormStyle;
end;

function TRLPreviewSetup.GetHelpContext: Integer;
begin
  Result:= DefaultHelpContext;
end;

function TRLPreviewSetup.GetHelpFile: string;
begin
  Result:= DefaultHelpFile;
end;

function TRLPreviewSetup.GetPosition: TPosition;
begin
  Result:= DefaultPosition;
end;

function TRLPreviewSetup.GetSentToPrinter: Boolean;
begin
  Result:= RLPreviewForm.SentToPrinter;
end;

function TRLPreviewSetup.GetShowModal: Boolean;
begin
  Result:= DefaultShowModal;
end;

function TRLPreviewSetup.GetWindowBounds: TRect;
begin
  Result:= DefaultWindowBounds;
end;

function TRLPreviewSetup.GetWindowState: TWindowState;
begin
  Result:= DefaultWindowState;
end;

function TRLPreviewSetup.GetZoomFactor: Double;
begin
  Result:= DefaultZoomFactor;
end;

function TRLPreviewSetup.IsZoomFactor: Boolean;
begin
  Result:= (DefaultZoomFactor <> 100);
end;

procedure TRLPreviewSetup.SetBorderIcons(const Value: TBorderIcons);
begin
  DefaultBorderIcons:= Value;
end;

procedure TRLPreviewSetup.SetCaption(const Value: string);
begin
  DefaultCaption:= Value;
end;

procedure TRLPreviewSetup.SetEditOptions(const Value: TRLPreviewEditOptionsSet);
begin
  FEditOptions:= Value;
end;

procedure TRLPreviewSetup.SetEnabledButtons(const Value: TRLPreviewFormButtonsSet);
begin
  FEnabledButtons:= Value;
end;

procedure TRLPreviewSetup.SetFormStyle(const Value: TFormStyle);
begin
  DefaultFormStyle:= Value;
end;

procedure TRLPreviewSetup.SetHelpContext(const Value: Integer);
begin
  DefaultHelpContext:= Value;
end;

procedure TRLPreviewSetup.SetHelpFile(const Value: string);
begin
  DefaultHelpFile:= Value;
end;

procedure TRLPreviewSetup.SetPosition(const Value: TPosition);
begin
  DefaultPosition:= Value;
end;

procedure TRLPreviewSetup.SetSentToPrinter(const Value: Boolean);
begin
  RLPreviewForm.SentToPrinter:= Value;
end;

procedure TRLPreviewSetup.SetShowModal(const Value: Boolean);
begin
  DefaultShowModal:= Value;
end;

procedure TRLPreviewSetup.SetWindowBounds(const Value: TRect);
begin
  DefaultWindowBounds:= Value;
end;

procedure TRLPreviewSetup.SetWindowState(const Value: TWindowState);
begin
  DefaultWindowState:= Value;
end;

procedure TRLPreviewSetup.SetZoomFactor(const Value: Double);
begin
  DefaultZoomFactor:= Value;
end;

procedure TRLPreviewForm.CreateParams(var Params: TCreateParams);
begin
  inherited CreateParams(Params);
  if ShowPreviewOnWindowsTaskBar then
    begin
      Params.ExStyle:= Params.ExStyle or WS_EX_APPWINDOW or WS_EX_NOPARENTNOTIFY;
      Params.WndParent:= GetDesktopwindow;
    end;
end;

procedure TRLPreviewForm.WMActivate(var Message: TWMActivate);
begin
  inherited;
  if ShowPreviewOnWindowsTaskBar and not IsWindowEnabled(Handle) then
    EnableWindow(Handle, True);
end;

procedure TRLPreviewForm.ButtonAnnulerenClick(Sender: TObject);
begin
  Close;
end;

procedure TRLPreviewForm.CMMouseWheel(var Message: TCMMouseWheel);
begin
  if GetKeyState(VK_CONTROL) < 0 then
    begin
      if message.WheelDelta > 0 then
        Preview.ZoomIn
      else
        Preview.ZoomOut;
    end
  else if message.WheelDelta > 0 then
    Preview.ScrollUp
  else
    Preview.ScrollDown;
end;

procedure TRLPreviewForm.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  case Key of
    VK_CONTROL:
      Preview.DisableCapture;
  end;
end;

procedure TRLPreviewForm.FormResize(Sender: TObject);
var
  PaddingLeftRight: Integer;
begin
  // Center Toolbar below preview document
  with PanelTools do
    begin
      AlignWithMargins:= True;
      Margins.Top:= 0;
      Margins.Bottom:= 0;
      PaddingLeftRight:= (PanelRight.Width - ToolbarWidth) div 2;
      if PaddingLeftRight >= 0 then
        begin
          Margins.Left:= PaddingLeftRight;
          Margins.Right:= PaddingLeftRight;
        end;
    end;
end;

procedure TRLPreviewForm.FormShow(Sender: TObject);

  procedure GetDuplexMode;
  var
    Device, Driver, Port: string;
    DriverHandle: THandle;
    DevModeRef: PDeviceMode;
  begin
    Printer.GetPrinter(Device, Driver, Port, DriverHandle);
    if DriverHandle <> 0 then
      begin
        DevModeRef:= GlobalLock(DriverHandle);
        if DevModeRef <> nil then
          try
            case DevModeRef^.dmDuplex of
              DMDUP_SIMPLEX:
                ComboBoxDuplex.ItemIndex:= 0;
              DMDUP_VERTICAL:
                ComboBoxDuplex.ItemIndex:= 1;
              DMDUP_HORIZONTAL:
                ComboBoxDuplex.ItemIndex:= 2;
            end;
          finally
            GlobalUnlock(DriverHandle);
          end;
      end;
  end;

begin
  if Preview.Pages.Orientation = MetaOrientationLandscape then
    RadioGroupLayout.ItemIndex:= 1
  else
    RadioGroupLayout.ItemIndex:= 0;
  SpinEditCopies.Value:= 1;
  EditPageSelection.Text:= '';
  if RLPrinter.SupportsDuplex then
    GetDuplexMode;
  ButtonAfdrukken.SetFocus;
end;

end.