🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Windows Printers (Bob Gonder please respond)

#12316
From: John Scott
Date: Tue, 16 Dec 2003 17:20
41 lines
2322 bytes
Hi Bob: I tried the code at my clients and it did not work. The code I tried
was:
    // Nov 2003 to print double sided
    char ADevice[256]={0}, ADriver[256]={0}, APort[256]={0};
    THandle  ADeviceMode;
    Printer()->GetPrinter(ADevice, ADriver, APort, ADeviceMode);
    LPDEVMODE DevMode=(LPDEVMODE)GlobalLock(&ADeviceMode);
    if (rgDuplex->ItemIndex==0)
    {
       DevMode->dmFields=DM_DUPLEX;
       //DevMode->dmDuplex=DMDUP_VERTICAL;
       DevMode->dmDuplex=DMDUP_HORIZONTAL;
    }
    else
    {
       DevMode->dmDuplex=DMDUP_SIMPLEX;
    }
    Printer()->SetPrinter(ADevice, ADriver, APort, ADeviceMode);
    GlobalUnlock(&ADeviceMode);
    // end of add Nov 2003
    if (StrToInt(lblMaxCount->Caption)>StrToInt(txtMax->Text))
      ProgressBar1->Max=StrToInt(txtMax->Text);
    else
      ProgressBar1->Max=StrToInt(lblMaxCount->Caption);
    // Now get the printer information
    Printer()->Orientation = poPortrait;
    Printer()->BeginDoc();

am I missing a step so that the line:
    LPDEVMODE DevMode=(LPDEVMODE)GlobalLock(&ADeviceMode);
and the line:
    GlobalUnlock(&ADeviceMode);

do not use the &. Your instructions did not have the & but if I leave it out
It generated errors when I compile.

The VCL has a PrinterSetupDialog object which lets the operator select
double sided printing and it then works ok but it would be better if it was
done by the code.

John
Technical Details
Message-ID: <3fdf3f3b@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!in.100proofnews.com!in.100proofnews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,db79f85f5b525ea6,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-12-16 09:29:06 PST
From: "John Scott" <jscott@kw.igs.net>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Windows Printers (Bob Gonder please respond)
Date: Tue, 16 Dec 2003 12:20:44 -0500
Lines: 43
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 216.16.227.113
Message-ID: <3fdf3f3b@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1071595323 216.16.227.113 (16 Dec 2003 09:22:03 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!fu-berlin.de!in.100proofnews.com!in.100proofnews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail