Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How change programaticaly PaperSize ?

1,434 views
Skip to first unread message

Luis Banda

unread,
Dec 30, 1998, 3:00:00 AM12/30/98
to
How can assign a value to a paper size of a report, give me error,
Incompatible types: 'TQRPaperSize' and ....

example:
Report_Sales.QuickRep1.Page.PaperSize:= ??

What I have that write in ??..
please help me.

- Luis Banda - <lba...@lared.net.pe>

P.D: I Use Delphi 3.0 C/S

Luis Banda

unread,
Dec 31, 1998, 3:00:00 AM12/31/98
to
Hello all

I was readed this forum, and probably ther is not solution for this and
other problems
reported by :
- Felipe Barcellos/Quick Report AND Custom size paper/ the 12/12
- zhoum163 /How can I set print' custom page in delphi / the 16/12
- darko / custom paper size / the 20/12

I was thinking that if somebody of you sends me the source code of the
QReport for D3, I probably could correct the bugs, and then send the
solution.

Prosper new year 1999, to Inprise family

Tobias Mueller

unread,
Jan 1, 1999, 3:00:00 AM1/1/99
to
Hi,

to use the standard papersizes you can use something like

QuickRep.Page.PaperSize := A4;

The A4 is definied in one of the following units: QUICKRPT, QrPrntr or
QRCtrls. Included all three and you'll have access to the QRPaperSize
constants.

If you use "QuickRep.Page.PaperSize := Custom;" then you have to set the
Length and Width of the report yourself. In addition you have to change the
printersettings from within your program. I wrote the following procedure to
do so:

=================
procedure TMainForm.SetPrinterProperties(Sequenze: Byte);
var ActPrinter : String;
PrintPort : String;
DevMode : PDeviceMode;
SubDevMode : TDeviceMode;
PrinterH : THandle;
DeviceMode : THandle;
begin
ActPrinter := Printer.Printers[Printer.PrinterIndex];
PrintPort := Copy(ActPrinter,Pos('an',ActPrinter)+3,(Pos(':',ActPrinter) -
(Pos('an',ActPrinter)+3)));
Delete(ActPrinter,Pos('an',ActPrinter)-1,Length(ActPrinter));

OpenPrinter(PChar(ActPrinter),PrinterH,nil);
DeviceMode := GlobalAlloc(GHND,DocumentProperties(0, PrinterH,
PChar(ActPrinter), SubDevMode, SubDevMode, 0));
if DeviceMode <> 0 then
begin
DevMode := GlobalLock(DeviceMode);
DocumentProperties(0, PrinterH, PChar(ActPrinter), DevMode^, DevMode^,
DM_OUT_BUFFER);

case Sequenze of
0: begin
// --> sets printerdriver to DIN-A4
DevMode.dmPaperSize := DMPAPER_A4;
DevMode.dmFields := DevMode.dmFields or DevMode.dmPaperSize;
end;
1: begin
// --> sets printerdriver to CUSTOM-SIZE
DevMode.dmPaperSize := DMPAPER_USER;
DevMode.dmPaperLength := 3050; // in 0.1 mm //
DevMode.dmPaperWidth := 2100; // in 0.1 mm //
DevMode.dmFields := DevMode.dmFields or DevMode.dmPaperSize or
DevMode.dmPaperLength or DevMode.dmPaperWidth;
end;
end;


DocumentProperties(0,PrinterH,PChar(ActPrinter),DevMode^,DevMode^,DM_IN_BUFF
ER or DM_UPDATE);

GlobalUnlock(DeviceMode);
GlobalFree(DeviceMode);
end;
end;

=================

perhaps it might be a starting point.

You see, everthing is possible without changing the source code. If you need
more help drop me an eMail to tobias...@swol.de

- Tobias (tobias...@swol.de)

Luis Banda

unread,
Jan 1, 1999, 3:00:00 AM1/1/99
to
Hello all

The problem is that the end user sometimes has paper A4 and sometimes
continuous form,
and that this could change the papername about agreement to their
necessities.
Is not this important?

- Luis Banda -

P.D: Tobias, thanks, I will analize your email.


Luis Banda

unread,
Jan 1, 1999, 3:00:00 AM1/1/99
to
thanks Tobias

I apreciate your help.

>to use the standard papersizes you can use something like
>
> QuickRep.Page.PaperSize := A4;
>
>The A4 is definied in one of the following units: QUICKRPT, QrPrntr or
>QRCtrls. Included all three and you'll have access to the QRPaperSize
>constants.

I have searched this constants in all the disk and no found, these
should be
of TQRPaperSize class and no the constants of Windows.pas

>If you use "QuickRep.Page.PaperSize := Custom;" then you have to set
the
>Length and Width of the report yourself. In addition you have to change
the
>printersettings from within your program. I wrote the following
procedure to
>do so:

Ok, your procedure change the printer properties, too the height and
width paper
, but to the moment to print, it output with the papersize defined in
the report.

Frankly, this matter has me obnoxious, because for this monday have to
solve it
and i am already with it like 2 weeks.

Anyone know the solution, or there is not solution. ???

TeamB you have the word.

Luis Banda

unread,
Jan 2, 1999, 3:00:00 AM1/2/99
to
with this code

Report_Sales.QuickRep1.Page.PaperSize:=qrpA4;

give me error: Incompatible types: 'TQRPaperSize' and 'TQR1PaperSize'

I think that the solution is a simple question, but who know ?

- Luis Banda -

Luis Banda

unread,
Jan 2, 1999, 3:00:00 AM1/2/99
to
Already, the point is solutioned.

with Report_Sales.QuickRep1 do
begin
Form2.QuickRep1.Page.PaperSize:=A4;
end;

Now, Why this function not return the active papername ?.

function GetPaperActive;


var ActPrinter : String;
PrintPort : String;
DevMode : PDeviceMode;
SubDevMode : TDeviceMode;
PrinterH : THandle;
DeviceMode : THandle;
begin
ActPrinter := Printer.Printers[Printer.PrinterIndex];

PrintPort := Copy(ActPrinter,Pos('on
LPT',ActPrinter)+3,(Pos(':',ActPrinter) -(Pos('on LPT',ActPrinter)+3)));

Delete(ActPrinter,Pos('on LPT',ActPrinter)-1,Length(ActPrinter));


OpenPrinter(PChar(ActPrinter),PrinterH,nil);
DeviceMode := GlobalAlloc(GHND,DocumentProperties(0,
PrinterH,PChar(ActPrinter), SubDevMode, SubDevMode, 0));

Result:=0;


if DeviceMode <> 0 then
begin
DevMode := GlobalLock(DeviceMode);
DocumentProperties(0, PrinterH, PChar(ActPrinter), DevMode^,

DevMode^,DM_IN_BUFFER);
Result:= DevMode.dmPaperSize; // not return correctly
end;
End;

Which is the error ?

- Luis Banda -

Tobias Mueller

unread,
Jan 2, 1999, 3:00:00 AM1/2/99
to
Answered via eMail

Tobias Mueller

unread,
Jan 2, 1999, 3:00:00 AM1/2/99
to
This is the correct way to do what you want:

function TForm_Impresion.GetPaperActive: Integer;


var ActPrinter : String;
PrintPort : String;
DevMode : PDeviceMode;
SubDevMode : TDeviceMode;
PrinterH : THandle;
DeviceMode : THandle;
begin
ActPrinter := Printer.Printers[Printer.PrinterIndex];
PrintPort := Copy(ActPrinter,Pos('on
LPT',ActPrinter)+3,(Pos(':',ActPrinter) -(Pos('on LPT',ActPrinter)+3)));
Delete(ActPrinter,Pos('on LPT',ActPrinter)-1,Length(ActPrinter));

OpenPrinter(PChar(ActPrinter),PrinterH,nil);
DeviceMode := GlobalAlloc(GHND,DocumentProperties(0,
PrinterH,PChar(ActPrinter), SubDevMode, SubDevMode, 0));

Result:=0;
if DeviceMode <> 0 then
begin
DevMode := GlobalLock(DeviceMode);

DevMode.dmFields := DevMode.dmFields or DevMode.dmPaperSize or

DevMode.dmOrientation;

DocumentProperties(0, PrinterH, PChar(ActPrinter), DevMode^,
DevMode^,DM_OUT_BUFFER);
ShowMessage('Papersize: '+inttostr(DevMode.dmPaperSize){+'
'+inttostr(DeviceMode)});
ShowMessage('Orientation: '+inttostr(DevMode.dmOrientation){+'
'+inttostr(DeviceMode)});

Result:= DevMode.dmPaperSize;
end;
End;

For more information see my second eMail the first one was a bit wrong :-))

-Tobias (tobias...@swol.de)

0 new messages