🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11454

Re: A5 paper problem with Printer()...

#11454
From: JD
Date: Thu, 12 Feb 2004 08:50
58 lines
2425 bytes
Hans Galema <dontusethis@dontusethis.nl> wrote:
>JD wrote:
>
> >> ... ask me how to do that.
>
>How would you do that ?

I was searching my database for something and found that I had
the code to do it!! It's in Delphi but no biggie.

~ JD


uses
  Windows, SysUtils, Classes, Printers, WinSpool;

var
  DevMode: PDeviceMode;
  DeviceMode: THandle;
  Device, Driver, Port: array [0..79] of char;
  pDevice, pDriver, pPort: PChar;

  // Stored name of supported papers
  PaperNames: array of array [0..63] of char;

procedure GetAllPapersData;
{
  Get all necessary data from Capabilities to prepared array
  - Paper names
  - Paper sizes code
  - Paper dimensions for each code
}

begin

  Printer.GetPrinter(pDevice, pDriver, pPort, DeviceMode);

  DevMode := GlobalLock(DeviceMode);

  NumberOfPapers:=
    DeviceCapabilities(pDevice, pPort, DC_PAPERSIZE, Nil, DevMode);

  // This array creation is the main reason why unit request D4+
  // Of course, this can be changed by pointer subtitues, but at
  // the moment this is used as an easyiest way

  SetLength(PaperNames,NumberOfPapers);
  SetLength(Papers,NumberOfPapers);
  SetLength(PaperSize,NumberOfPapers);

  DeviceCapabilities(pDevice,pPort,DC_PAPERS,PChar(Papers),DevMode);
  DeviceCapabilities(pDevice,pPort,DC_PAPERNAMES,PChar(PaperNames),DevMode);
  DeviceCapabilities(pDevice,pPort,DC_PAPERSIZE,PChar(PaperSize),DevMode);

  GlobalUnLock(DeviceMode);

end;
Technical Details
Message-ID: <402b3e55@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <402a06d7$1@newsgroups.borland.com> <402a8040$1@newsgroups.borland.com> <402aa15e$1@newsgroups.borland.com> <402abf46@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,fef64b246f0c620e
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-12 01:09:40 PST
From: "JD" <nospam@nospam.com>
Sender: "JD" <nospam@nospam.com>
Reply-To: "JD" <nospam@nospam.com>
Subject: Re: A5 paper problem with Printer()...
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 172.174.170.192     
References: <402a06d7$1@newsgroups.borland.com> <402a8040$1@newsgroups.borland.com> <402aa15e$1@newsgroups.borland.com> <402abf46@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <402b3e55@newsgroups.borland.com>
Date: 12 Feb 2004 00:50:29 -0800
X-Trace: newsgroups.borland.com 1076575829 207.105.83.66 (12 Feb 2004 00:50:29 -0800)
Lines: 59
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail