From f711f277e7a881b919a35e54811e4ebff527a949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20L=C3=B6rtscher?= Date: Thu, 26 Nov 2015 18:16:44 +0100 Subject: [PATCH] More versatile preset configuration options for the print options dialog --- Source/EmbeddedWB.pas | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Source/EmbeddedWB.pas b/Source/EmbeddedWB.pas index bb77095..d42b53a 100644 --- a/Source/EmbeddedWB.pas +++ b/Source/EmbeddedWB.pas @@ -177,6 +177,10 @@ TPrintOptions = class(TPersistent) FFooter: string; FMargins: TMargins; FOrientation: TPrintOrientationOption; + FPreferredPaperFormat: string; + FPrintBackgroundImages: Boolean; + FAdjustToSize: Boolean; + FDisableHeadersAndFooters: Boolean; FMeasure: TMeasure; procedure SetHTMLHeader(const Value: Tstrings); public @@ -189,6 +193,10 @@ TPrintOptions = class(TPersistent) property HTMLHeader: TStrings read FHTMLHeader write SetHTMLHeader; property Footer: string read FFooter write FFooter; property Orientation: TPrintOrientationOption read FOrientation write FOrientation; + property PreferredPaperFormat: string read FPreferredPaperFormat write FPreferredPaperFormat; + property PrintBackgroundImages: Boolean read FPrintBackgroundImages write FPrintBackgroundImages; + property AdjustToSize: Boolean read FAdjustToSize write FAdjustToSize; + property DisableHeadersAndFooters: Boolean read FDisableHeadersAndFooters write FDisableHeadersAndFooters; end; {============================================================================} @@ -1250,6 +1258,37 @@ procedure TEmbeddedWB.HandleDialogBoxes(var AMsg: Messages.TMessage); SendDlgItemMessage(PopHandle, $0420, BM_CLICK, 0, 0) else SendDlgItemMessage(PopHandle, $0421, BM_CLICK, 0, 0); + + // try to select preferred paper format + // (if it doesn't exists, the default selection won't be touched) + if FPrintOptions.FPreferredPaperFormat <> '' then + begin + PreferredPaperFormatIndex := SendDlgItemMessage( + PopHandle, $0471, CB_FINDSTRING, WParam(-1), + LParam(PChar(FPrintOptions.FPreferredPaperFormat))); + + if PreferredPaperFormatIndex <> CB_ERR then + SendDlgItemMessage(PopHandle, $0471, CB_SETCURSEL, PreferredPaperFormatIndex, 0); + end; + + // enable or disable the background image printing checkbox as acquired + if FPrintOptions.FPrintBackgroundImages then + CheckDlgButton(PopHandle, $0410, BST_CHECKED) + else + CheckDlgButton(PopHandle, $0410, BST_UNCHECKED); + + // enable or disable the adjust to size checkbox as acquired + if FPrintOptions.FAdjustToSize then + CheckDlgButton(PopHandle, $0411, BST_CHECKED) + else + CheckDlgButton(PopHandle, $0411, BST_UNCHECKED); + + // disable all header and footers by selecting + // the first element if desired + if FPrintOptions.FDisableHeadersAndFooters then + for CtrlID := $1fe0 to $1fe5 do + SendDlgItemMessage(PopHandle, CtrlID, CB_SETCURSEL, 0, 0); + SetDlgItemText(PopHandle, $1FD3, PChar(FPrintOptions.FHeader)); SetDlgItemText(PopHandle, $1FD5, PChar(FPrintOptions.FFooter)); SetDlgItemText(PopHandle, $0483, PChar(PrintMarginStr(FPrintOptions.FMargins.FLeft)));