[Lazarus] PrinterSetupDialog1.Execute won't work.

Larry Dalton larrydalton71 at gmail.com
Wed Aug 26 22:07:17 CEST 2015


I can't get PrinterSetupDialog1.Execute to work on Lazarus 1.4.2, FPC
2.6.4, on Windows 7.

I couldn't get it to work in a program that I have used for a long time, so
I built a simple test program, and get the same error code.

Here is the complete program:

unit printertestunit;

{$mode objfpc}{$H+}

interface

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

type

  { TPrinterTest }

  TPrinterTest = class(TForm)
    Button1: TButton;
    PageSetupDialog1: TPageSetupDialog;
    PrintDialog1: TPrintDialog;
    PrinterSetupDialog1: TPrinterSetupDialog;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  PrinterTest: TPrinterTest;

implementation

{$R *.lfm}

{ TPrinterTest }

procedure TPrinterTest.Button1Click(Sender: TObject);
var message_string:string;
begin
  PrinterSetupDialog1.Execute;
    if PrintDialog1.Execute then message_string:='Executed ok' else
message_string:=
    'Not executed';
    if messagedlg(message_string,mtconfirmation,[mbok],0)=mrok then
end;

procedure TPrinterTest.FormCreate(Sender: TObject);
begin

end;

end.


{here is the lpr}
 program printertest;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,printertestunit
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms, printertestunit, printer4lazarus
  { you can add units after this };

{$R *.res}

var MyTest:TPrinterTest;
begin
  RequireDerivedFormResource := True;
  Application.Initialize;
  MyTest:=TPrinterTest.Create(application);
  Application.Run;
end.

Required Packages are LCL and Printer4lazarus.

When I execute button1click I get the following error:
"Project printertest raised exception class 'RunError(217)'"

Clicking on Continue I get the subsequent error message:
Project printertest raised exception class 'EControlC' with message:
'Control-C hit.'

Any ideas on this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20150826/2fb2a706/attachment-0002.html>


More information about the Lazarus mailing list