Solved

Choose paper tray

Posted on 2000-03-02
4
597 Views
Last Modified: 2010-04-04
I have a HP-8100DN printer which provides two paper tray (both are A4),
the trays are labeled tray2 and tray3.
I want to insert plain A4 paper in tray2 and preprinted-A4 in tray3.
I will print 2 or 3 pages with plain-A4 and then some pages with preprinted-A4 within my program. I want to know if there is a way to control which tray to select paper from ?
Thanks to any help.
0
Comment
Question by:flao
4 Comments
 
LVL 1

Expert Comment

by:yk030299
ID: 2579400
if you are using D5, you can specify the outputBin.
0
 

Expert Comment

by:ellessar
ID: 2579582
With quickreports you also have the printersettings.outputbin property of the report:


In the OnBeforePrint event of your detail band just add:

if QRPrinter.PageNumber = 1 then
begin

  if  PrinterSettings.OutputBin <> First then
    PrinterSettings.OutputBin := First;

end
else
  if QRPrinter.PageNumber = 4 then
  begin

    if  PrinterSettings.OutputBin <> First then
      PrinterSettings.OutputBin := Last;

  end;
0
 
LVL 17

Accepted Solution

by:
inthe earned 100 total points
ID: 2581299
Hi
this example shows how to specify the paper size etc and trays / bins to print to:

unit Unit1;

interface

uses
  Windows, Messages,Printers, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port   : array[0..255] of char;
hDMode : THandle;
PDMode : PDEVMODE;
begin
  Printer.GetPrinter(Device, Driver, Port, hDMode);
  if hDMode <> 0 then begin
    pDMode := GlobalLock(hDMode);
    if pDMode <> nil then begin

     {Set to legal}
      pDMode^.dmFields := pDMode^.dmFields or dm_PaperSize;
      pDMode^.dmPaperSize := DMPAPER_LEGAL;

     {Set to custom size}
      pDMode^.dmFields := pDMode^.dmFields or
                          DM_PAPERSIZE or
                          DM_PAPERWIDTH or
                          DM_PAPERLENGTH;
      pDMode^.dmPaperSize := DMPAPER_USER;
      pDMode^.dmPaperWidth := 100 {SomeValueInTenthsOfAMillimeter};
      pDMode^.dmPaperLength := 100 {SomeValueInTenthsOfAMillimeter};

     {Set the bin to use}
      pDMode^.dmFields := pDMode^.dmFields or DMBIN_MANUAL;
      pDMode^.dmDefaultSource := DMBIN_MANUAL;

      GlobalUnlock(hDMode);
   end;
  end;
Printer.PrinterIndex := Printer.PrinterIndex;  Printer.BeginDoc;
Printer.Canvas.Font.Name := 'Courier New';
Printer.Canvas.Font.Size := 10;
Printer.Canvas.Font.Color:=ClRed;
Printer.Canvas.TextOut(100,100, 'Test 1');
Printer.EndDoc;
end;
end.

Regards Barry
0
 
LVL 1

Expert Comment

by:Indefrei
ID: 2581997
additional to Barry's answer
you find the dmbin_params in windows.pas in

....borland\Delphi\source\rtl\bin

cheers
Indi
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 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

16 Experts available now in Live!

Get 1:1 Help Now