Changing Paper Tray when Printing

Hi all !!

I would like to be able to Change the Printer Tray in my program, So it is possible to print the first page from the upper tray and the rest from the lower tray.

Is there a generel way to do this, whitout knowing what kind of printer it is.... I know the printer might not have more than one tray, but in those cases it schould be ignored

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

This is dependant on the printer driver and hardware and is highly proprietary in nature. You would need to not only check the printer/driver attached, but you will also need the printer specific API since this is not a "standard" printing option even under Windows.
kwang080897Author Commented:
Okomoto :

Hi !

Thanks for participating, i will just reopen this question for a few days.

You might be right, and if thats the case i will of course grade you answer.

but i really need this function, and i just can't bellive It can't be done in a more generel way.

I can see that in Word 97 it is posible to use one tray for first page and another for the rest.

That way would work for me to... (to obtain a list of trays and choose)

Hello Kwang,

A few months ago I had a similar problem. Posting question I got answer from Inthe.
There is a unit called Windows.pas in Borland\Delphi\Source\RTL\WIN directory.It contains a lot of definitions for paper sizes, paper bins etc. I'm sure you will find there what you need. See under headings <paper selections> and <bin selections>.
Hope helps.

Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

Hi, it's me again.

Here I'm posting a part of code I use, which has been inspired by Inthe. Actually, I have not tried to change the printer tray, but successfully changed the printer paper. I suppose you'llneed something similar, especially the statement:

procedure TReportForm.PrintReportBtnClick(Sender: TObject);
    Device : array[Byte] of Char;
    Driver : array[Byte] of Char;
    Port   : array[Byte] of Char;
    hDMode : THandle;
    pDMode : PDEVMODE;
    PRN:textfile ;
    Printer.GetPrinter(Device, Driver, Port, hDMode);
    if hDMode <> 0 then
        pDMode := GlobalLock(hDMode);
        if pDMode <> nil then
           {Set to A3}
           pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
           pDMode^.dmPaperSize := DMPAPER_A3;
           pDMode^.dmDefaultSource := DMBIN_UPPER; {!!!}
    for I:=1 to  8 do Writeln(PRN);
    for I:=0 to ReportMemo.Lines.Count-1 do
      Writeln(PRN,CharRow(' ',8),ReportMemo.Lines[I]);


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
yes see jo's last comment that is the way to change paper and bin sizes :-)
kwang080897Author Commented:
Hi !!!


Thanks ! - I will test this in a few days and return.... Havent got the time now

Inthe :

Hope You enjoy the recykling, if this works i will be more than happy to reward you too - after all it is your solution.


I'll Be back in a few days
kwang080897Author Commented:
Almost Perfect !!

Except I'll have to Close the Printer with a Printer.Enddoc if i want to change the tray (oterwise Printer is Busy )- this means that my one job will look like more jobs when printing (using enddoc every time)...

Any suggestions ??
Sorry i dont know if its possible to change tray "on the fly" using delphi's tprinter object without enddoc :-(
kwang080897Author Commented:
Sorry !!!

I Forgot about this one.....

Fatman : Please post an answer

Inthe... I will submit a question for your old answer as well


kwang080897Author Commented:
Well - guess you dont have to..... i could myself..
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.