Solved

Changing the bin of the printer?

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

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

18 Experts available now in Live!

Get 1:1 Help Now