[Lazarus] How to use TPrintDialog

tim launchbury tim at tlaunchbury.ukfsn.org
Wed Jan 12 16:09:49 CET 2011


Hello all

I am trying to implement printing in my app and want to use the
printdialog included with lazarus. I have dropped the print dialog on
the form and set it to appear when a button is clicked.

When the printdialog.execute function is executed an exception is
generated. The exception is 
"Project raised exception class 'EReadError' with message:
Unknown property :"Caption""

This is followed by

"Project raised exception class 'EReadError' with message:
Error reading pgCopies.Caption: Unknown property :"Caption""

I have tried all the suggestions I could found on the wiki and the
delphi site. 

my code is as follows:

unit Unit1; 

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
StdCtrls, Printers, PrintersDlgs;

type

  { TForm1 }

  TForm1 = class(TForm)
    Button1: TButton;
    PrintDialog1: TPrintDialog;
    procedure Button1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end; 

var
  Form1: TForm1; 

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
  if printdialog1.execute then
  begin
    writeln(' ');
  end;
end;

end.
            
This problem occurrs with lazarus 0.9.29 revision 28950 and fpc 2.4.0
in linux with gtk2

Any suggestions or corrections would be gratefully
received.

Tim




More information about the Lazarus mailing list