Can any one knows the solution? Thanks.
uses Printer;
var Prt: TPrinter;
procedure TForm1.PrintProc;
begin
with Prt do begin
BeginDoc;
.........
NewPage.....
......
EndDoc;
end;
end;
In the OnCreate method of the form use: Prt := TPrinter.Create, in the
OnDestroy method of the form use Prt.Free.
When you use the predeclared Printer variable, you must not create and
destroy it.
Ben Chan <ben_...@usa.net> az alábbiakat írta a következő hírüzenetben:
385721DB...@usa.net...
I can print things successfully using a standalone printer through LPT
but when I use network printers, AccessViolation occurs whenever executing
"BeginDoc"....
Do you have a small code snippet that compiles that I can try?
Davie
I get the same access violation, but if you continue the program execution
you will see that it is complaining about "No Default Printer".
It comes as a result of the delphi (and the delphi IDE) app thinking there
is no default printer if you only have networked printers, or if the
networked printer is the default.
(BTW: I am using D3 and D5, both of which exibit the problem)
There is a default, but it cant see it !
Another delphi programmer told me that the default printer needs to be
stored in UPPER case in the registry for Delphi to be able to understand it,
but this doesnt always work (nor do the entries remain uppercased).
If anyone has a solution to this problem, could then e-mail it to me as well
as posting to the group, as I dont get a chance to check the group that
often.
I dont think any kind of "code snippet" would be of use if you system is
working at the mo due to it being a Delphi functionality issue as opposed to
a programming issue.
Thanks
Adrian Bawn, Intermediate IT Systems Engineer
E-mail: adria...@uk.coltgroup.com
Davie Reed wrote in message <3859D754...@smatters.com>...
Adrian, perhaps the following thread i saved some time ago can help you fix
the problem:
<quote>
"No default printer" problem on NT
My problem : I am using several WinNT workstations that cannot print (only
when using Delphi apps)
----------------------------------------------------------------------------
--------------------------
Tried NT4-SP4&5
I have completely reinstalled the Delphi IDE, etc on another workstation -
same results
( PS older NT workstation-SP3 appears to work OK ?!?!?!? )
Now . . . .
The Delphi PRINTERS unit has a procedure SetToDefaultPrinter
This uses the WINAPI call . . . . .
EnumPrinters(PRINTER_ENUM_DEFAULT, nil, 5, PrinterInfo, ByteCnt, ByteCnt,
StructCnt)
& if it fails, it raises an exception with message "There is no default
printer . . . ." AND THEN NO PRINTING
HOWEVER, the WINAPI Help description for EnumPrinters indicates clearly that
the PRINTER_ENUM_DEFAULT option is ONLY available with Windows95 and NOT
under WinNT.
[Aside: The August 1999 TechNET indicates that the parameters for
EnumPrinters are different for Win95 & WinNT]
Is the Delphi PRINTERS unit in error ??
If so, how do I fix it ?
From: "Brian Cahill" <Brian...@SoftHome.net>
Newsgroups: borland.public.delphi.winapi
Subject: Re: <Default Printer> problem ( BUG ?? )
Date: Thu, 19 Aug 1999 08:23:17 +1000
FOUND (I think !)
Did a little more digging - found that the ENUMPRINTERS device names are in
full uppercase
whereas the DefaultPrinter comes back with the server name part in lower
case !!
In a 'local' copy of the PRINTERS unit, I changed the comparison line to
if Uppercase(TPrinterDevice(Objects[I]).Device) = Uppercase(Device)
AND it works OK !
</quote>
Peter Below (TeamB) 10011...@compuserve.com)
No replies in private e-mail, please, unless explicitly requested!
Sent using Virtual Access 5.00 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe