Article

From:
To:
Peter Below (TeamB)
Subject:
Re: Error: "Printer selected is not valid."
Newsgroup:
borland.public.delphi.nativeapi.win32

Re: Error: "Printer selected is not valid."

I changed the code as suggested and now I get the error:  'System Error.
Code: 1801. The printer name is invalid'.  I have been searching the web for
clues on this one but haven't found anything yet.  If anyone has an idea
please let me know.

Regards, Edward

"Peter Below (TeamB)" <✉compuXXserve.com> wrote in message
news:VA.0000b23c.005636cc@nomail.please...

> As a test copy the Printers.pas unit to your project directory and change the
> code a little:

> >     if Assigned(CreateHandleFunc) then
> >       with TPrinterDevice(Printers.Objects[PrinterIndex]) do
> >       begin
> >         DC := CreateHandleFunc(PChar(Driver), PChar(Device), PChar(Port),
> > DevMode);
>
> Replace that line with
>         DC := CreateHandleFunc(PChar(Driver), PChar(Device), nil, DevMode);
>
> >         if DC = 0 then RaiseError(SInvalidPrinter);
>
> Replace this line with
>           if DC = 0 then
>             if Sysutils.Win32Platform = VER_PLATFORM_WIN32_NT then
>               RaiseLastOSError
>             else
>               RaiseError(SInvalidPrinter);
>
> >         if FCanvas <> nil then FCanvas.Handle := DC;
>
> Run some tests. If the call to create the device context handle fails you
> should at least get a more informative error message.
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Fri, 22 Nov 2024 23:57:20 UTC
Copyright © 2009-2024
HREF Tools Corp.