(* ImageEn Build 7.0.0.06.2637 @ 7-4-17 14:58:42.679 *) (* Copyright (c) 1998-2017 by Carlotta Calandra. All rights reserved. Copyright (c) 2011-2017 by Xequte Software. This software comes without express or implied warranty. In no case shall the author be liable for any damage or unwanted behavior of any computer hardware and/or software. Author grants you the right to include the component in your application, whether COMMERCIAL, SHAREWARE, or FREEWARE. ImageEn, IEvolution and ImageEn ActiveX may not be included in any commercial, shareware or freeware libraries or components. www.ImageEn.com *) (* File version 1008 *) unit ieprnform2; {$R-} {$Q-} {$I ie.inc} {$IFDEF IEINCLUDEPRINTDIALOGS} interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, ImageEnView, ImageEnIO, ieview, hyiedefs, ComCtrls, ImageEnProc, ievect, ExtCtrls, ImgList, hyieutils, iexBitmaps, iesettings, iexLayers, iexRulers; type TfiePrnForm2 = class(TForm) GroupBox1: TGroupBox; Edit1: TEdit; Label1: TLabel; Label2: TLabel; Edit2: TEdit; Label3: TLabel; Edit3: TEdit; Label4: TLabel; Edit4: TEdit; grpOther: TGroupBox; edtGamma: TEdit; lblGamma: TLabel; grpPreview: TGroupBox; ImageEnView1: TImageEnView; UpDown1: TUpDown; UpDown2: TUpDown; UpDown3: TUpDown; UpDown4: TUpDown; updGamma: TUpDown; PrinterSetupDialog1: TPrinterSetupDialog; Image1: TImage; grpSizeLocation: TGroupBox; cmbPosition: TComboBox; cmbPrintSize: TComboBox; lblSize: TLabel; lblPosition: TLabel; edtWidth: TEdit; updWidth: TUpDown; edtHeight: TEdit; updHeight: TUpDown; lblWidth: TLabel; lblHeight: TLabel; lblWidthUnit: TLabel; lblHeightUnit: TLabel; lblMeasurement: TLabel; ComboBox2: TComboBox; pnlButtons: TPanel; btnSetup: TBitBtn; btnOK: TBitBtn; btnCancel: TBitBtn; lblPagesWide: TLabel; edtPagesWide: TEdit; updPagesWide: TUpDown; lblPagesHigh: TLabel; edtPagesHigh: TEdit; updPagesHigh: TUpDown; imlPositions: TImageList; procedure cmbPrintSizeChange(Sender: TObject); procedure btnOKClick(Sender: TObject); procedure PrintPreview(Sender: TObject); procedure FormActivate(Sender: TObject); procedure UpDown1Click(Sender: TObject; Button: TUDBtnType); procedure UpDown2Click(Sender: TObject; Button: TUDBtnType); procedure UpDown3Click(Sender: TObject; Button: TUDBtnType); procedure UpDown4Click(Sender: TObject; Button: TUDBtnType); procedure updGammaClick(Sender: TObject; Button: TUDBtnType); procedure updWidthClick(Sender: TObject; Button: TUDBtnType); procedure updHeightClick(Sender: TObject; Button: TUDBtnType); procedure btnSetupClick(Sender: TObject); procedure cmbPositionDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); procedure ComboBox2Change(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCreate(Sender: TObject); procedure updPagesHighClick(Sender: TObject; Button: TUDBtnType); procedure updPagesWideClick(Sender: TObject; Button: TUDBtnType); private { Private declarations } fHaveActivated: Boolean; procedure IncDecMargins(text: TEdit; Button: TUDBtnType); procedure IncDecValue(text: TEdit; Button: TUDBtnType); procedure SetLanguage_units; function UnitMult: double; Procedure UpdateDialogSize; procedure UpdatePrintSizeControls(); public { Public declarations } io: TImageEnIO; fDialogsMeasureUnit: TIEDialogsMeasureUnit; fTaskName: string; fPrintPreviewParams: TIOPrintPreviewParams; PrintAnnotations: boolean; activating: boolean; procedure UpdateLanguage(); procedure LoadParameters; procedure SaveParameters; {$IFDEF UNIT_TESTING} procedure SetNextLanguage; {$ENDIF} end; implementation uses iexThemes, printers, iexCanvasUtils; {$R *.DFM} const // Items of cmbPrintSize - MUST ALIGN WITH TIESize _cmbPrintSize_Normal = 0; _cmbPrintSize_FitToPage = 1; _cmbPrintSize_StretchToPage = 2; _cmbPrintSize_FillPage = 3; _cmbPrintSize_SpecifiedSize = 4; _cmbPrintSize_MultiplePages = 5; {$IFDEF UNIT_TESTING} procedure tfiePrnForm2.SetNextLanguage; begin Self.Tag := Self.Tag + 1; if Self.tag >= ord( msUser ) then Self.Tag := 0; IEGlobalSettings().MsgLanguage := TMsgLanguage(Self.Tag); UpdateLanguage(); end; {$ENDIF} function tfiePrnForm2.UnitMult: double; begin if (fDialogsMeasureUnit = ieduCm) or (fDialogsMeasureUnit = ieduSelectableDefCm) then Result := CM_per_Inch else Result := 1; end; procedure tfiePrnForm2.LoadParameters; begin // get parameters from fPrintPreviewParams Edit1.Text := FloatToStrF(fPrintPreviewParams.MarginTop, ffGeneral, 4, 4); Edit2.Text := FloatToStrF(fPrintPreviewParams.MarginLeft, ffGeneral, 4, 4); Edit3.Text := FloatToStrF(fPrintPreviewParams.MarginRight, ffGeneral, 4, 4); Edit4.Text := FloatToStrF(fPrintPreviewParams.MarginBottom, ffGeneral, 4, 4); cmbPosition.ItemIndex := ord(fPrintPreviewParams.Position); cmbPrintSize.ItemIndex := integer(fPrintPreviewParams.Size); UpdatePrintSizeControls(); if ( fPrintPreviewParams.Width > 0 ) and ( fPrintPreviewParams.Size <> psMultiplePages ) then edtWidth.Text := FloatToStrF(fPrintPreviewParams.Width, ffGeneral, 4, 4) else edtWidth.Text := FloatToStrF( (io.fPrintBitmap.Width / io.Params.DpiX) * UnitMult , ffGeneral, 4, 4); if ( fPrintPreviewParams.Height > 0 ) and ( fPrintPreviewParams.Size <> psMultiplePages ) then edtHeight.Text := FloatToStrF(fPrintPreviewParams.Height, ffGeneral, 4, 4) else edtHeight.Text := FloatToStrF( (io.fPrintBitmap.Height / io.Params.DpiY) * UnitMult, ffGeneral, 4, 4); if ( fPrintPreviewParams.Width > 0 ) and ( fPrintPreviewParams.Size = psMultiplePages ) then edtPagesWide.Text := IntToStr( Trunc( fPrintPreviewParams.Width )); if ( fPrintPreviewParams.Height > 0 ) and ( fPrintPreviewParams.Size = psMultiplePages ) then edtPagesHigh.Text := IntToStr( Trunc( fPrintPreviewParams.Height )); edtGamma.Text := FloatToStrF(fPrintPreviewParams.Gamma, ffGeneral, 4, 4); end; procedure tfiePrnForm2.SaveParameters; begin // Assign parameters to fPrintPreviewParams fPrintPreviewParams.MarginTop := IEStrToFloatDefS(Edit1.Text, 1); fPrintPreviewParams.MarginLeft := IEStrToFloatDefS(Edit2.Text, 1); fPrintPreviewParams.MarginRight := IEStrToFloatDefS(Edit3.Text, 1); fPrintPreviewParams.MarginBottom := IEStrToFloatDefS(Edit4.Text, 1); fPrintPreviewParams.Position := TIOPrintPreviewPosition(cmbPosition.ItemIndex); fPrintPreviewParams.Size := TIOPrintPreviewSize(cmbPrintSize.ItemIndex); if fPrintPreviewParams.Size = psSpecifiedSize then begin fPrintPreviewParams.Width := IEStrToFloatDefS(edtWidth.Text, 6); fPrintPreviewParams.Height := IEStrToFloatDefS(edtHeight.Text, 4); end else if fPrintPreviewParams.Size = psMultiplePages then begin fPrintPreviewParams.Width := StrToIntDef( edtPagesWide.Text, 6 ); fPrintPreviewParams.Height := StrToIntDef( edtPagesHigh.Text, 4 ); end else begin fPrintPreviewParams.Width := -1; fPrintPreviewParams.Height := -1; end; fPrintPreviewParams.Gamma := IEStrToFloatDefS(edtGamma.Text, 1); end; procedure TfiePrnForm2.FormActivate(Sender: TObject); var bCanSetMeasureUnits: Boolean; begin // Prevent double calls to FormActivate if fHaveActivated then exit; fHaveActivated := True; Application.ProcessMessages; // first draws all controls (to avoid "Swiss Cheese") activating := true; if IEGlobalSettings().UseButtonGlyphsInDialogs = False then begin btnOK.Glyph := nil; btnSetup.Glyph := nil; btnCancel.Glyph := nil; cmbPosition.Style := csDropDownList; end; LoadParameters; if cmbPrintSize.ItemIndex < 0 then cmbPrintSize.ItemIndex := 1; bCanSetMeasureUnits := (fDialogsMeasureUnit = ieduSelectableDefInches) or (fDialogsMeasureUnit = ieduSelectableDefCm); lblMeasurement .Visible := bCanSetMeasureUnits; ComboBox2 .Visible := bCanSetMeasureUnits; if (fDialogsMeasureUnit = ieduSelectableDefInches) then ComboBox2.ItemIndex := 0 else if (fDialogsMeasureUnit = ieduSelectableDefCm) then ComboBox2.ItemIndex := 1; activating := false; UpdateDialogSize; PrintPreview(Sender); end; // Change Size combobox procedure TfiePrnForm2.cmbPrintSizeChange(Sender: TObject); begin UpdatePrintSizeControls(); PrintPreview(Sender); end; procedure TfiePrnForm2.UpdatePrintSizeControls(); var bSpecifiedSize : Boolean; bMultiplePages : Boolean; begin bSpecifiedSize := cmbPrintSize.ItemIndex = _cmbPrintSize_SpecifiedSize; edtWidth .Enabled := bSpecifiedSize; updWidth .Enabled := bSpecifiedSize; edtHeight .Enabled := bSpecifiedSize; updHeight .Enabled := bSpecifiedSize; lblWidth .Enabled := bSpecifiedSize; lblHeight .Enabled := bSpecifiedSize; lblWidthUnit .Enabled := bSpecifiedSize; lblHeightUnit .Enabled := bSpecifiedSize; bMultiplePages := cmbPrintSize.ItemIndex = _cmbPrintSize_MultiplePages; edtPagesWide .Visible := bMultiplePages; edtPagesHigh .Visible := bMultiplePages; updPagesWide .Visible := bMultiplePages; updPagesHigh .Visible := bMultiplePages; lblPagesWide .Visible := bMultiplePages; lblPagesHigh .Visible := bMultiplePages; edtWidth .Visible := not bMultiplePages; updWidth .Visible := not bMultiplePages; edtHeight .Visible := not bMultiplePages; updHeight .Visible := not bMultiplePages; lblWidth .Visible := not bMultiplePages; lblHeight .Visible := not bMultiplePages; lblWidthUnit .Visible := not bMultiplePages; lblHeightUnit .Visible := not bMultiplePages; end; // OK (print) procedure TfiePrnForm2.btnOKClick(Sender: TObject); begin SaveParameters; PrintPreview(Sender); end; // Preview or print procedure TfiePrnForm2.PrintPreview(Sender: TObject); var VerticalPos: TIEVerticalPos; HorizontalPos: TIEHorizontalPos; Size: TIESize; MarginLeft, MarginTop, MarginRight, MarginBottom, SpecWidth, SpecHeight, GammaCorrection: double; lc: TCursor; begin if activating then exit; VerticalPos := ievpCenter; HorizontalPos := iehpCenter; if TIOPrintPreviewPosition(cmbPosition.ItemIndex) in [ppTopLeft, ppTop, ppTopRight] then VerticalPos := ievpTop; if TIOPrintPreviewPosition(cmbPosition.ItemIndex) in [ppBottomLeft, ppBottom, ppBottomRight] then VerticalPos := ievpBottom; if TIOPrintPreviewPosition(cmbPosition.ItemIndex) in [ppTopLeft, ppLeft, ppBottomLeft] then HorizontalPos := iehpLeft; if TIOPrintPreviewPosition(cmbPosition.ItemIndex) in [ppTopRight, ppRight, ppBottomRight] then HorizontalPos := iehpRight; Size := iesFitToPage; case cmbPrintSize.ItemIndex of _cmbPrintSize_Normal : Size := iesNormal; _cmbPrintSize_FitToPage : Size := iesFitToPage; _cmbPrintSize_StretchToPage : Size := iesFitToPageStretch; _cmbPrintSize_FillPage : Size := iesFillPage; _cmbPrintSize_SpecifiedSize : Size := iesSpecifiedSize; _cmbPrintSize_MultiplePages : Size := iesMultiplePages; end; MarginLeft := IEStrToFloatDefS(Edit2.Text, 0) / UnitMult; MarginTop := IEStrToFloatDefS(Edit1.Text, 0) / UnitMult; MarginRight := IEStrToFloatDefS(Edit3.Text, 0) / UnitMult; MarginBottom := IEStrToFloatDefS(Edit4.text, 0) / UnitMult; if Size = iesMultiplePages then begin SpecWidth := IEStrToFloatDefS( edtPagesWide.Text, 1 ); SpecHeight := IEStrToFloatDefS( edtPagesHigh.Text, 1 ); end else begin SpecWidth := IEStrToFloatDefS(edtWidth.Text, 1) / UnitMult; if SpecWidth = 0 then SpecWidth := 0.001; SpecHeight := IEStrToFloatDefS(edtHeight.Text, 1) / UnitMult; if SpecHeight = 0 then SpecHeight := 0.001; end; GammaCorrection := IEStrToFloatDefS(edtGamma.Text, 1); lc := Screen.Cursor; Screen.Cursor := crHourGlass; if Sender = btnOK then begin // PRINT IMAGE Printer.Title := fTaskName; Printer.BeginDoc; io.PrintImageEx( io.fPrintBitmap, Printer.Canvas, -1, -1, -1, -1, MarginLeft, MarginTop, MarginRight, MarginBottom, VerticalPos, HorizontalPos, Size, SpecWidth, SpecHeight, GammaCorrection); Printer.EndDoc; end else begin // PREVIEW IMAGE ONLY io.PreviewPrintImageEx( io.fPrintBitmap, ImageEnView1.Bitmap, ImageEnView1.IdealImageWidth, ImageEnView1.IdealImageHeight, Printer, MarginLeft, MarginTop, MarginRight, MarginBottom, VerticalPos, HorizontalPos, Size, SpecWidth, SpecHeight, GammaCorrection); ImageEnView1.Update; ImageEnView1.Fit; end; Screen.Cursor := lc; end; procedure tfiePrnForm2.SetLanguage_units; begin if (fDialogsMeasureUnit = ieduInches) or (fDialogsMeasureUnit = ieduSelectableDefInches) then begin // inches GroupBox1.Caption := ' ' + iemsg(IEMSG_MARGINS) + ' (' + iemsg(IEMSG_INCHES) + ') '; lblWidthUnit .Caption := iemsg(IEMSG_INCHES); lblHeightUnit.Caption := iemsg(IEMSG_INCHES); end else begin // centimeters (Cm) GroupBox1.Caption := ' ' + iemsg(IEMSG_MARGINS) + ' (' + IEGlobalSettings().MeasureUnits[ieuCENTIMETERS] + ') '; lblWidthUnit .Caption := IEGlobalSettings().MeasureUnits[ieuCENTIMETERS]; lblHeightUnit.Caption := IEGlobalSettings().MeasureUnits[ieuCENTIMETERS]; end; end; procedure tfiePrnForm2.UpdateLanguage(); var bEnglish : Boolean; begin bEnglish := (IEGlobalSettings().MsgLanguage = msEnglish) or ((IEGlobalSettings().MsgLanguage = msSystem) and (syslocale.PriLangID = LANG_ENGLISH)); Caption := iemsg(IEMSG_PRINT); SetLanguage_units; Label1.Caption := iemsg(IEMSG_TOP) + ':'; Label2.Caption := iemsg(IEMSG_LEFT) + ':'; Label3.Caption := iemsg(IEMSG_RIGHT) + ':'; Label4.Caption := iemsg(IEMSG_BOTTOM) + ':'; grpPreview.Caption := ' ' + iemsg(IEMSG_PREVIEW) + ' '; cmbPrintSize.Items[ _cmbPrintSize_Normal ] := iemsg( IEMSG_NORMAL ); cmbPrintSize.Items[ _cmbPrintSize_FitToPage ] := iemsg( IEMSG_FITTOPAGE ); cmbPrintSize.Items[ _cmbPrintSize_StretchToPage ] := iemsg( IEMSG_STRETCHTOPAGE ); cmbPrintSize.Items[ _cmbPrintSize_FillPage ] := iemsg( IEMSG_FILLPAGE ); cmbPrintSize.Items[ _cmbPrintSize_SpecifiedSize ] := iemsg( IEMSG_SPECIFIEDSIZE ); cmbPrintSize.Items[ _cmbPrintSize_MultiplePages ] := iemsg( IEMSG_MULTIPLEPAGES ); btnOK.Caption := iemsg(IEMSG_OK); btnCancel.Caption := iemsg(IEMSG_CANCEL); btnSetup.Caption := iemsg(IEMSG_PRINTSETUP) + '...'; ComboBox2.Items[0] := iemsg(IEMSG_INCHES); grpOther.Caption := ' ' + iemsg(IEMSG_OTHER) + ' '; lblGamma.Caption := iemsg(IEMSG_GAMMACORRECTION) + ':'; lblWidth .Caption := iemsg(IEMSG_WIDTH) + ':'; lblHeight .Caption := iemsg(IEMSG_HEIGHT) + ':'; lblMeasurement.Caption := iemsg(IEMSG_MEASUREUNITS) + ':'; cmbPosition.Clear; cmbPosition.Items.Add(iemsg(IEMSG_TOPLEFT)); cmbPosition.Items.Add(iemsg(IEMSG_TOPCENTER)); cmbPosition.Items.Add(iemsg(IEMSG_TOPRIGHT)); cmbPosition.Items.Add(iemsg(IEMSG_CENTERLEFT)); cmbPosition.Items.Add(iemsg(IEMSG_CENTER)); cmbPosition.Items.Add(iemsg(IEMSG_CENTERRIGHT)); cmbPosition.Items.Add(iemsg(IEMSG_BOTTOMLEFT)); cmbPosition.Items.Add(iemsg(IEMSG_BOTTOMCENTER)); cmbPosition.Items.Add(iemsg(IEMSG_BOTTOMRIGHT)); lblPagesWide.Caption := iemsg(IEMsg_PagesAcross) + ':'; lblPagesHigh.Caption := iemsg(IEMsg_PagesDown) + ':'; grpSizeLocation .Caption := ' ' + iemsg(IEMSG_LOCATIONSIZE) + ' '; lblPosition .Caption := iemsg(IEMSG_POSITION) + ':'; if bEnglish then lblSize.Caption := 'Print Size:' // English text too short else lblSize.Caption := iemsg(IEMSG_SIZE) + ':'; end; procedure TfiePrnForm2.IncDecMargins(text: TEdit; Button: TUDBtnType); begin case Button of btNext: text.Text := FloatToStrF(dmax(IEStrToFloatDefS(text.Text, 0) + IEGlobalSettings().PrintDialogMarginsIncrement, IEGlobalSettings().PrintDialogMarginsMinValue), ffGeneral, 4, 4); btPrev: text.Text := FloatToStrF(dmax(IEStrToFloatDefS(text.Text, 0) - IEGlobalSettings().PrintDialogMarginsIncrement, IEGlobalSettings().PrintDialogMarginsMinValue), ffGeneral, 4, 4); end; end; procedure TfiePrnForm2.IncDecValue(text: TEdit; Button: TUDBtnType); begin case Button of btNext: text.Text := IntToStr( StrToIntDef(text.Text, 0) + 1 ); btPrev: text.Text := IntToStr( imax(1, StrToIntDef(text.Text, 0) - 1 )); end; end; procedure TfiePrnForm2.UpDown1Click(Sender: TObject; Button: TUDBtnType); begin IncDecMargins(Edit1, Button); end; procedure TfiePrnForm2.UpDown2Click(Sender: TObject; Button: TUDBtnType); begin IncDecMargins(Edit2, Button); end; procedure TfiePrnForm2.UpDown3Click(Sender: TObject; Button: TUDBtnType); begin IncDecMargins(Edit3, Button); end; procedure TfiePrnForm2.UpDown4Click(Sender: TObject; Button: TUDBtnType); begin IncDecMargins(Edit4, Button); end; procedure TfiePrnForm2.updGammaClick(Sender: TObject; Button: TUDBtnType); begin case button of btNext: edtGamma.Text := FloatToStrF(dmax(IEStrToFloatDefS(edtGamma.Text, 0) + 0.1, 0), ffGeneral, 4, 4); btPrev: edtGamma.Text := FloatToStrF(dmax(IEStrToFloatDefS(edtGamma.Text, 0) - 0.1, 0), ffGeneral, 4, 4); end; end; procedure TfiePrnForm2.updWidthClick(Sender: TObject; Button: TUDBtnType); begin IncDecMargins(edtWidth, Button); end; procedure TfiePrnForm2.updHeightClick(Sender: TObject; Button: TUDBtnType); begin IncDecMargins(edtHeight, Button); end; // Setup procedure TfiePrnForm2.btnSetupClick(Sender: TObject); begin PrinterSetupDialog1.Execute; PrintPreview(self); end; procedure TfiePrnForm2.cmbPositionDrawItem(Control: TWinControl; Index: Integer; Rect: TRect; State: TOwnerDrawState); var iGlyph : Integer; sText : string; begin iGlyph := Index; sText := cmbPosition.Items[Index]; IEDrawComboListBoxItem( TCombobox(Control).Canvas, Rect, Control.Enabled, sText, imlPositions, iGlyph); end; // units procedure TfiePrnForm2.ComboBox2Change(Sender: TObject); var pred: TIEDialogsMeasureUnit; xmult: double; begin pred := fDialogsMeasureUnit; if ComboBox2.ItemIndex = 0 then fDialogsMeasureUnit := ieduSelectableDefInches else fDialogsMeasureUnit := ieduSelectableDefCm; if pred <> fDialogsMeasureUnit then begin if pred = ieduSelectableDefCm then xmult := 1 / CM_per_Inch else xmult := CM_per_Inch; Edit1.Text := FloatToStrF(IEStrToFloatDefS(Edit1.Text, 0) * xmult, ffGeneral, 4, 4); Edit2.Text := FloatToStrF(IEStrToFloatDefS(Edit2.Text, 0) * xmult, ffGeneral, 4, 4); Edit3.Text := FloatToStrF(IEStrToFloatDefS(Edit3.Text, 0) * xmult, ffGeneral, 4, 4); Edit4.Text := FloatToStrF(IEStrToFloatDefS(Edit4.Text, 0) * xmult, ffGeneral, 4, 4); edtWidth.Text := FloatToStrF(IEStrToFloatDefS(edtWidth.Text, 0) * xmult, ffGeneral, 4, 4); edtHeight.Text := FloatToStrF(IEStrToFloatDefS(edtHeight.Text, 0) * xmult, ffGeneral, 4, 4); SetLanguage_units; end; end; procedure TfiePrnForm2.FormClose(Sender: TObject; var Action: TCloseAction); begin // Save parameters if they print or close, but do not cancel If ModalResult <> mrCancel then SaveParameters; end; procedure TfiePrnForm2.FormCreate(Sender: TObject); // Set an image as ImageEnView wallpaper aligned to a specific control so it appears continuous procedure _AssignOffsetWallpaper(IEView: TImageEnView; ABitmap: TBitmap; OffSetToControl: TControl); var SourceRect, DestRect: TRect; begin SourceRect.Left := IEView.ClientOrigin.X - OffSetToControl.ClientOrigin.X; SourceRect.Top := IEView.ClientOrigin.Y - OffSetToControl.ClientOrigin.Y; // Use full width in case ImageEnView is enlarged SourceRect.Right := SourceRect.Left + ABitmap.Width; SourceRect.Bottom := SourceRect.Top + ABitmap.Height; IEView.Wallpaper.Bitmap.Width := SourceRect.Right - SourceRect.Left; IEView.Wallpaper.Bitmap.Height := SourceRect.Bottom - SourceRect.Top; IEView.Wallpaper.Bitmap.PixelFormat := pf24bit; DestRect := Rect( 0, 0, IEView.Wallpaper.Bitmap.Width, IEView.Wallpaper.Bitmap.Height ); IEView.Wallpaper.Bitmap.Canvas.CopyRect( DestRect, ABitmap.Canvas, SourceRect ); end; begin fHaveActivated := False; IEInitializeComboBox( cmbPosition ); ImageEnView1.Background := IEGlobalSettings().PreviewImageBackgroundColor; ImageEnView1.BackgroundStyle := IEGlobalSettings().PreviewImageBackgroundStyle; if IEGlobalSettings().DialogBackgroundStyle <> iedbDefault then begin case IEGlobalSettings().DialogBackgroundStyle of iedbPaper : begin ImageEnView1.Background := clWhite; IECreateOSXBackgroundPaper( Image1.Picture.Bitmap, Image1.Width, Image1.Height ); end; iedbMetal : begin ImageEnView1.Background := clSilver; IECreateOSXBackgroundMetal( Image1.Picture.Bitmap, Image1.Width, Image1.Height ); end; iedbCustom: begin Image1.Picture.Bitmap.Width := Image1.Width; Image1.Picture.Bitmap.Height := Image1.Height; TileBitmapOntoCanvas( Image1.Picture.Bitmap.Canvas, Image1.Width, Image1.Height, IEGlobalSettings().DialogBackgroundImage ); end; end; Image1.Update; _AssignOffsetWallpaper( ImageEnView1, Image1.Picture.Bitmap, Image1 ); end; // Match background of panel if ( ImageEnView1.BackgroundStyle = iebsSolid ) and ( ImageEnView1.Background = clBtnFace ) then begin ImageEnView1.Background := GetThemeColor( ietpPanel, clBtnFace ); if ImageEnView1.Background < 0 then ImageEnView1.Background := GetSysColor( ImageEnView1.Background and $000000FF); // Normalize system colors so ImageEnView1 does not try to theme it end; // Move controls to display positions edtPagesWide .Top := edtWidth.Top; updPagesWide .Top := updWidth.Top; edtPagesHigh .Top := edtHeight.Top; updPagesHigh .Top := updHeight.Top; lblPagesWide .Top := lblWidth.Top; lblPagesHigh .Top := lblHeight.Top; end; Procedure TfiePrnForm2.UpdateDialogSize; var iBottomMargin: Integer; begin iBottomMargin := lblMeasurement.Left; // Suitable approximation if ComboBox2.Visible then grpOther.Height := ComboBox2.Top + ComboBox2.Height + iBottomMargin else grpOther.Height := edtGamma.Top + edtGamma.Height + iBottomMargin; grpPreview.Height := grpOther.Top + grpOther.Height - grpPreview.Top; ImageEnView1.Height := grpPreview.Height - (ImageEnView1.Top + 6); pnlButtons.Top := grpPreview.Top + grpPreview.Height + 2; ClientHeight := pnlButtons.Top + pnlButtons.height; end; procedure TfiePrnForm2.updPagesHighClick(Sender: TObject; Button: TUDBtnType); begin IncDecValue(edtPagesHigh, Button); end; procedure TfiePrnForm2.updPagesWideClick(Sender: TObject; Button: TUDBtnType); begin IncDecValue(edtPagesWide, Button); end; {$ELSE} // {$ifdef IEINCLUDEPRINTDIALOGS} interface implementation {$ENDIF} end.