ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Print dialog settings reset button
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

spurgeon

54 Posts

Posted - Feb 10 2022 :  16:01:07  Show Profile  Reply
I'd like to save and load print settings (https://www.imageen.com/help/index.php?topic=TIOPrintPreviewParams.LoadFromFile), but I also want the user to be able to reset the dialog to defaults.

Is it possible to add a Reset button on the print dialog(s) to restore the defaults in an upcoming release?

Here's an example of what I'm thinking:

xequte

38189 Posts

Posted - Feb 10 2022 :  21:16:59  Show Profile  Reply
Hi

We'll consider that for a future update. You can add custom controls to dialogs using:

https://www.imageen.com/help/TIEView.OnShowDialog.html



Nigel
Xequte Software
www.imageen.com
Go to Top of Page

spurgeon

54 Posts

Posted - Feb 11 2022 :  15:40:20  Show Profile  Reply
Thanks for the docs reference. I added this code below, which seems to work if any others are interested:


procedure TMyForm.Print(printSettingsFilePath: WideString);
begin
  if ImageEnVect1.IO.Params.ImageCount > 1 then begin
    if FileExists( printSettingsFilePath ) then begin
      ImageEnMView1.MIO.PrintPreviewParams.LoadFromFile(printSettingsFilePath);
    end;
    ImageEnMView1.MIO.DoPrintPreviewDialog;
    ImageEnMView1.MIO.PrintPreviewParams.SaveToFile(printSettingsFilePath);
  end else begin
    if FileExists( printSettingsFilePath ) then begin
      ImageEnVect1.IO.PrintPreviewParams.LoadFromFile(printSettingsFilePath);
    end;
    ImageEnVect1.IO.DoPrintPreviewDialog(iedtDialog);
    ImageEnVect1.IO.PrintPreviewParams.SaveToFile(printSettingsFilePath);
  end;
end;
procedure TMyForm.ImageEnVect1ShowDialog(Sender: TObject;
  DlgType: TIEDlgType; Form: TForm);
begin
  if DlgType = iefPrintPreview then begin
    with TfiePrnForm2(Form) do
    begin
      // Create Reset button so users can reset the form values
      with TButton.Create( Form ) do
      begin
        Parent := Form;
        Left := btnSetup.Left + btnSetup.Width + {add same spacing as between OK and Cancel buttons} (btnCancel.Left - (btnOK.Left + btnOK.Width));
        Top := btnSetup.Top;
        Width := btnCancel.Width;
        Height := btnSetup.Height;
        Anchors := [akBottom, akLeft];
        Caption := iemsg(IEMSG_RESET); // Use ImageEn's localized string
        OnClick := PrintResetClicked;
      end;
    end;
  end else if DlgType = iefMultiPrintPreview then begin
    // TODO: Not sure where to put Reset button in layout yet
  end;
end;
procedure TMyForm.PrintResetClicked(Sender: TObject);
begin
  // Create a blank new version of TIOPrintPreviewParams with defaults
  FreeAndNil(TfiePrnForm2(TButton(Sender).Parent).fPrintPreviewParams); // free existing params so we can initialize new ones
  TfiePrnForm2(TButton(Sender).Parent).fPrintPreviewParams := TIOPrintPreviewParams.Create; // the Create constructor initializes defaults
  // Load the paramters into the print form
  TfiePrnForm2(TButton(Sender).Parent).LoadParameters;
  // Refresh the remaining items on the form -- TfiePrnForm2 (ieprnform2.pas) calls PrintPreview at the end of FormActivate to set the state of the window, so we repeat that here
  TfiePrnForm2(TButton(Sender).Parent).PrintPreview(nil);
end;
Go to Top of Page

xequte

38189 Posts

Posted - Feb 11 2022 :  22:19:24  Show Profile  Reply
Hi

You can email me for an update, which supports fPrintPreviewParams.Reset();

Nigel
Xequte Software
www.imageen.com
Go to Top of Page

spurgeon

54 Posts

Posted - Feb 14 2022 :  14:55:01  Show Profile  Reply
Thanks, much appreciated. Will fPrintPreviewParams.Reset(); be available in the next official 10.x release as well?
Go to Top of Page

xequte

38189 Posts

Posted - Feb 15 2022 :  03:57:01  Show Profile  Reply
Yes, it will.

Nigel
Xequte Software
www.imageen.com
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: