Solved

Can I change the Paper size at runtime?

Posted on 2000-04-19
4
193 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now