Solved

Can I change the Paper size at runtime?

Posted on 2000-04-19
4
196 Views
Last Modified: 2010-04-04
I want to change a Qreport from A3 to A4, How can I do that at runtime?

thanks
0
Comment
Question by:kelvinyu
  • 2
  • 2
4 Comments
 
LVL 1

Accepted Solution

by:
ronvp earned 50 total points
ID: 2733591
To set the report paper size just do like this:
         
aReport.Page.PaperSize := A4
or back

aReport.Page.PaperSize := A3;

Note that when you change paper size that your controls may not always prinht correctly..

also here is a tip.. If you design reports in Landscape A4, and then change to Portrait A3, you will keep your report looking good and get more records on a page..

Switching from landscape to portrait is done like this:
 
aReport.Page.Orientation := poPortrait;

Before you switch from A4 to A3 from within your code, you may check if the printer actually supports A3 like this:

(function returns TRUE if the printer supports A3 or 11" x 17"

Function PrinterHasA3: Boolean;
var Device, Driver, Port: array[0..255] of char;
    ADevMode: THandle;
    Rslt: integer;
    i: integer;
    PN: Array of Word;
Begin
   Screen.Cursor := crHourGlass;
   Result := False;
   with Printer do
       GetPrinter(Device, Driver, Port, ADevMode);
   // Get the number of paper names
   Rslt := DeviceCapabilitiesA(Device, Port, DC_PAPERS, nil, nil);
   if Rslt > 0 then begin
     SetLength(PN, Rslt);
     try
       // Retrieve the list of names into memory
       if DeviceCapabilitiesA(Device, Port, DC_PAPERS, Pointer(PN), nil) = - 1 then
          raise Exception.Create('Device capabilites error');
       // Check the paper names
       for i := 0 to Rslt - 1 do
          If (PN[i] = DMPAPER_11X17) or (PN[i] = DMPAPER_A3) then begin
             Result := True;
             Break;
          end;
     finally
       PN := NIL;
    end;
  end;
  Screen.Cursor := crDefault;
end;

0
 

Author Comment

by:kelvinyu
ID: 2733669
ronvp:

I have tried this method before, while complie the program ,it met a error message - "Undeclared Indentifier:'A4'"
Should I use some UNITs?
0
 
LVL 1

Expert Comment

by:ronvp
ID: 2734987
Kelvinyu,

You must have QRPrntr in your uses clause..

Ron
0
 

Author Comment

by:kelvinyu
ID: 2742586
The Report Size can be changed now
Thanks you
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question