Solved

Changing the bin of the printer?

Posted on 1998-10-22
4
256 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
  • 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

Title # Comments Views Activity
Delphi Spellcheck in Webbrowser 1 43
Show Listview image from database (String field) 5 143
QRReport  TQrmemo vertical stretching 1 55
Base1 Encode/Decode 3 85
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 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