Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

TppPrinterDialog access violation

When I try to open it

lPrintDialog := TppPrintDialog.create(self);
lPrintDialog.AllowPrintToArchive := false;
lPrintDialog.allowprinttofile := true;
lPrintDialog.DeviceType := dtScreen;
lPrintDialog.LanguageIndex := 7;
pp_report.printer.printername := nome_stampante;
lPrintDialog.printer := pp_report.printer;
lPrintDialog.textfilename := pp_report.textfilename;

//lPrintDialog.btnPrinterProperties.enabled := false;
lPrintDialog.rdbCurrentPage.enabled := false;
lPrintDialog.rdbPages.enabled := false;
lPrintDialog.edtPageRange.enabled := false;
lPrintDialog.edtPageRange.color := clBtnFace;
lPrintDialog.cbxPrintWhat.enabled := false;
lPrintDialog.cbxPrintWhat.color := clBtnFace;

if lPrintDialog.ShowModal <> mrOk then

I receive an access violation
Fabio Codebue
P-Soft
web: https://www.p-soft.biz
Firebird Foundation Commitee Member

Comments

  • and naturally printer dialog will open but no printers found!
    and there are printers
    Fabio Codebue
    P-Soft
    web: https://www.p-soft.biz
    Firebird Foundation Commitee Member
  • Hi Fabio,

    The printer dialog is not designed to be created as a stand-alone option. If you would like to only display the printer dialog, you can simply set the DeviceType property of the report to "Printer" and the print dialog will display when calling Report.Print.

    ppReport1.DeviceType := 'Printer';
    ppReport1.Print;
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • Nico
    I use this code from 2010 and I never had problems. Just now when I upgrade latest RB version for Delphi Alexandria
    Fabio Codebue
    P-Soft
    web: https://www.p-soft.biz
    Firebird Foundation Commitee Member
  • Hi Fabio,

    The printer dialog has gone through a number of major changes since 2010. Please explain what you are trying to accomplish with your application and I will try to find a solution with the current architecture.


    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • I have a form where user can choose
    1. print preview
    2. print to printer
    3. send by mail (with pdf attachment)

    this is a generic form use to inherited all printer form.

    If use rchoose 2 case usually I open printer dialog where user can
    . choose a printer (from compuer instaleld printers)
    - choose to print to
    - file
    - excel (raw data or report like)
    - csv, txt
    - PDF
    - and so on...

    Fabio Codebue
    P-Soft
    web: https://www.p-soft.biz
    Firebird Foundation Commitee Member
  • Hi Fabio,

    Thanks for the clarification. The print dialog is designed to print reports only so using in this way may cause problems in the future as we enhance the feature.

    For now, you need to make a call to TppPrintDialog.Init before showing the dialog to initialize the new high DPI image lists. This is generally necessary with all ReportBuilder dialogs.
    //lPrintDialog.btnPrinterProperties.enabled := false;
    lPrintDialog.rdbCurrentPage.enabled := false;
    lPrintDialog.rdbPages.enabled := false;
    lPrintDialog.edtPageRange.enabled := false;
    lPrintDialog.edtPageRange.color := clBtnFace;
    lPrintDialog.cbxPrintWhat.enabled := false;
    lPrintDialog.cbxPrintWhat.color := clBtnFace;

    lPrintDialog.Init; //Initialize Print Dialog

    if lPrintDialog.ShowModal <> mrOk then
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • It works... realy thanks... have a nice weekend
    Fabio Codebue
    P-Soft
    web: https://www.p-soft.biz
    Firebird Foundation Commitee Member
Sign In or Register to comment.