Solved

Changing the bin of the printer?

Posted on 1998-10-22
4
257 Views
Last Modified: 2010-04-06
Hi!

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.

//Daniel
0
Comment
Question by:Dippen
[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 8

Accepted Solution

by:
ZifNab earned 50 total points
ID: 1343918
Hi Dippen,

1.
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.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  
   {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.TextOut(100,100, 'Test 1');
  Printer.EndDoc;
 end;

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

Regards, Zif.
0
 

Author Comment

by:Dippen
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?

//Daniel
0
 
LVL 8

Expert Comment

by:ZifNab
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)

Http://www.skzl.nl/~hsteigstra

Zif.
0
 

Author Comment

by:Dippen
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.

//Daniel
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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…
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 https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

752 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