Changing the bin of the printer?

Posted on 1998-10-22
Last Modified: 2010-04-06

I know how to retrieve the name of the available bins for a specific printer. I also know how to change papersize and -orientation programmatically...
BUT how do I tell the printer what bin to use, programmatically?
And can I change bins in the middle of a printout (page 1 requires Manual Feed and page 2 uses the Default Tray)?

I use D2, W98.

Question by:Dippen
  • 2
  • 2

Accepted Solution

ZifNab earned 50 total points
ID: 1343918
Hi Dippen,

procedure TForm1.Button1Click(Sender: TObject);
  Device : array[0..255] of char;
  Driver : array[0..255] of char;
  Port : array[0..255] of char;
  hDMode : THandle;
  Printer.PrinterIndex := Printer.PrinterIndex;
  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  
     pDMode^.dmPaperLength := 100

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

  Printer.PrinterIndex := Printer.PrinterIndex;
  Printer.Canvas.TextOut(100,100, 'Test 1');

2. Don't know...
   But you can if you do this
   change bin
   use begindoc, enddoc
   change bin
   use begindoc, enddoc

Regards, Zif.

Author Comment

ID: 1343919
Hi, Zif!

Do you by any chance know what the available constants for setting the BIN are (besides DMBIN_MANUAL)? I couldn't find them in the online-help?


Expert Comment

ID: 1343920
Hi Dippen,

unfortunately I don't know...

But with this function

DWORD DeviceCapabilities(

    LPCTSTR  pDevice,      // pointer to a printer-name string
    LPCTSTR  pPort,      // pointer to a port-name string
    WORD  fwCapability,      // device capability to query
    LPTSTR  pOutput,      // pointer to the output
    CONST DEVMODE *  pDevMode       // pointer to structure with device data  

And using DC_BINS, you should get them... but i'm not sure about this.

while searching for an answer on your second q'n, I heard about the existance of this component : (it is shareware dough)



Author Comment

ID: 1343921
OK, thanks! I'll see what I can figure out myself. For example, I've found out that the constant DMBIN_UPPER and DMBIN_LOWER also exists.


Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
can't find the executable in Simulator 1 90
Delphi: Connect to running MS Outlook 4 86
Graphics32 under Delphi 10.1 Berlin 2 67
Delphi: sending SMS on android platform 1 21
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…

777 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