🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: More on Dialogs

#1670
From: JD
Date: Thu, 28 Jun 2007 08:06
59 lines
3202 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>
> [...] Both dialogs call the TPrinter::SetPrinter() method.
> For example (translated from the dialog source code):

That is what I'm doing but that doesn't address my original
concern about the length of the printer name. It is my current
understanding that one must first set the PrinterIndex before
one calls SetPrinter.

Simple enough if one uses Printers::IndexOf method but that
will only work if the string is an exact match and the printer
names in Printers are not limited to 32 bytes. Now, the docs
for DEVNAMES says it's 32 bytes and it must match DEVMODE
exactly but I just found this in the docs for PRINTDLGEX:

    Note that the dmDeviceName member of the DEVMODE structure
    also specifies a printer name. However, dmDeviceName is
    limited to 32 characters, and the wDeviceOffset name is
    not.

Obviousely there's an error there and I assume that the error
is that dmDeviceName and the string pointed to by wDeviceOffset
need not match exactly so I can use wDeviceOffset with IndexOf.
I just don't have a printer installed that's longer than 32
bytes to test it. Is there a way for me to lengthen a printer's
name?

>  // TPrinter takes ownership of the DeviceMode so do not free it...

Don't I need to dispose of the TPrinter's current DEVMODE? For
example:


    if( PageSetupDlg(&psd) )
      {
          unsigned int hDevMode;
          char ADevice[MAX_PATH], ADriver[MAX_PATH], APort[MAX_PATH];

          Printer()->PrinterIndex = Printer()->Printers->IndexOf( 
(char*)pDevNames + pDevNames->wDeviceOffset );
          Printer()->GetPrinter( ADevice, ADriver, APort, hDevMode );

          DEVNAMES *pDevNames = (DEVNAMES *) GlobalLock( psd.hDevNames );
          Printer()->SetPrinter( (char*)pDevNames + 
pDevNames->wDeviceOffset,
                                 (char*)pDevNames + 
pDevNames->wDriverOffset,
                                 (char*)pDevNames + 
pDevNames->wOutputOffset,
                                 (int)pds.hDevMode);

          GlobalFree( (void*)hDevMode );
          GlobalFree( psd.hDevNames );
      }

Thanks.

~ JD
Technical Details
Message-ID: <46836c01@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!194.25.134.62.MISMATCH!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46825ff3@newsgroups.borland.com> <46829422$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,964b3d9a83e56201
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "JD" <nospam@nospam.com>
From: "JD" <nospam@nospam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <46825ff3@newsgroups.borland.com> <46829422$1@newsgroups.borland.com>
Subject: Re: More on Dialogs
Date: Thu, 28 Jun 2007 03:06:21 -0500
Lines: 61
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2869
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 172.132.250.201
Message-ID: <46836c01@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1183017985 172.132.250.201 (28 Jun 2007 01:06:25 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsgate.cistron.nl!xs4all!feeder.news-service.com!194.25.134.62.MISMATCH!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail