In article <412fa09f$✉newsgroups.borland.com>, Edward wrote:
> I have a Delphi 7 project that prints to a plastic card printer using the > Printers.pas unit and calling "BeginDoc". I have updated to the latest > driver for the newer model printer and I've also tried using Windows 2000 > and Windows XP to see if Windows was part of the issue but it isn't. When > "BeginDoc" is called using the old plastic card printer it works, but using > the newer model (and corresponding new driver), I get this error when > "BeginDoc" is called: "exception class EPrinter....Printer Selected is not > Valid". Specifically, the line causing the failure (see "printers.pas" code > below) is "if DC - 0 then RaiseError(SInvalidPrinter);
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.
-- Peter Below (TeamB) Use the newsgroup archives : http://www.mers.com/searchsite.html http://www.tamaracka.com/search.htm http://groups.google.com http://www.prolix.be