Solved

Can I change the Paper size at runtime?

Posted on 2000-04-19
4
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

705 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