Is there an easy way, or do you have to make assignment statements to do
this, like:
MyReport.PrinterSettings.Copies := Printer.Copies;
etc. ??
Thanks in advance,
Jack
"Jack N.A. Bakker" <JA...@no.spam.RULLF2.LeidenUniv.NL> wrote in message
news:8gucg1$oi...@bornews.borland.com...
MyReport.PrinterSettings.PrinterIndex := Printer.PrinterIndex;
This does not seem to work, the way you propose:
I now have the following lines in my MyReport.BeforePrint event:
PrinterSetupDialog1.Execute;
MyReport.PrinterSettings.PrinterIndex := Printer.PrinterIndex;
and this does not work: When I change the printer settings, the report still
gets printed using the default settings.
Any other ideas?
TIA!
Jack
<no direct mail please (Colin Acheson)> wrote in message
news:3933b036...@newsgroups.borland.com...
It doesn't work. I always got the same error "printer out of range".
Any Idea?
Stephane
procedure TfrmQRepPreview.PrintButtonClick(Sender: TObject);
begin
with PrintDialog do
begin
FromPage := 1;
ToPage := QRUserPreview.QRPrinter.PageCount;
MinPage := 1;
MaxPage := QRUserPreview.QRPrinter.PageCount;
end;
if PrintDialog.Execute then
with PrintDialog do
// for the Quickrep print
If QRUserPreview.QRPrinter.Master is TQuickRep then
with TQuickRep(QRUserPreview.QRPrinter.Master) do
begin
printersettings.FirstPage := FromPage;
printersettings.LastPage := ToPage;
printersettings.Copies := Copies;
Printersettings.PrinterIndex := Printers.Printer.PrinterIndex;
QRUserPreview.QRPrinter.Print
end
else
// for the CompositeReport print
with TQRPatch(QRUserPreview.QRPrinter.Master).ParentReport do
begin
printersettings.FirstPage := FromPage;
printersettings.LastPage := ToPage;
printersettings.Copies := Copies;
Printersettings.PrinterIndex := Printers.Printer.PrinterIndex;
QRUserPreview.QRPrinter.Print
end;
end;
Everything works fine. You can try.
Regards,
Stefan
"Stephane Veillette" <veill...@biotonix.com> wrote in message
news:8h16os$lb...@bornews.borland.com...
if PrinterSetupDialog1.Execute then
MyReport.PrinterSettings.PrinterIndex := Printer.PrinterIndex;
Regards,
Colin Acheson
There is a bug in the D3 printers unit where, when you select another
printer, it sometimes does not return the chosen printer's correct
index. Instead it adds that printers name again to the end of the
printer list and returns an invalid index.
The error is at approx. line 411 of Printers.pas in the following
function:
function TPrinterDevice.IsEqual(ADriver, ADevice, APort: PChar):
Boolean;
The function is a one-liner. In Delphi 3, it is:
Result := (Device = ADevice) and (Port = APort);
This should be replaced with the Delphi 5 equivalent, which is:
Result := (Device = ADevice) and ((Port = '') or (Port = APort));
Regards,
Colin Acheson
is there a way in Delphi 5 to change the windows default printer???
I've looked in the help files but I can't find anything.
Maybe it's the better way to correct the bug.
Stephane
<no direct mail please (Colin Acheson)> wrote in message
news:3934e0b9...@newsgroups.borland.com...
See also my second reply to Jack.
As it is not working for either you or Stephane but is reliable for
me, the problem must relate to the point in time at which you are
assigning the PrinterIndex to the report's PrinterSettings.
It needs to be after the report form is created yet before it is
previewed or printed. On the face of it, the BeforePrint event would
seem to be a good place but perhaps it is too late.
I always create my report forms dynamically, so I put the assignment
code either in the FormCreate method of the form on which the QuickRep
resides or in the calling form as per the following example: (Note
that the QuickRep component is named "Report")
FormBillingRep := TFormBillingRep.Create(nil);
with FormBillingRep do
try
Report.PrinterSettings.PrinterIndex := Printer.PrinterIndex;
Report.Preview; // or Report.Print;
finally
Close;
Free;
end;
As well as freeing the form, you also need some code in the OnClose
event of the form to free the QuickRep itself, eg.
procedure TFormBillingRep.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Report.Free;
end;
Regards,
Colin Acheson
On Tue, 30 May 2000 21:54:30 +0200, "Jack N.A. Bakker"
<JA...@no.spam.RULLF2.LeidenUniv.NL> wrote:
>Colin,
>
>This does not seem to work, the way you propose:
>
>I now have the following lines in my MyReport.BeforePrint event:
<remainder snipped>
> As well as freeing the form, you also need some code in the OnClose
> event of the form to free the QuickRep itself, eg.
>
> procedure TFormBillingRep.FormClose(Sender: TObject;
> var Action: TCloseAction);
> begin
> Report.Free;
> end;
Why do you need this? Surely if the form is the owner of the report, it
will free it when it is, itself, freed?
--Bill Sparrow--
it's working with the current code :
QuickRep.PrinterSettings.PrinterIndex := Printer.PrinterIndex;
QuickRep.PrinterSettings.ApplySettings(QuickRep.Printer);
Thank for you help :)
Stephane
<no direct mail please (Colin Acheson)> wrote in message
news:3935c8e1...@newsgroups.borland.com...
> Stephane,
>
> See also my second reply to Jack.
>
> Regards,
> Colin Acheson
>
Regards,
Colin Acheson
It's working fine with one program (OCX) but not in the other, with the same
code for printing.
here's the code:
with PrintDialog1 do
begin
PrintDialog1.FromPage := 1;
PrintDialog1.ToPage := QuickRep.PageNumber;
PrintDialog1.MaxPage := QuickRep.PageNumber;
if Execute = true then
begin
QuickRep.PrinterSettings.FirstPage := FromPage;
QuickRep.PrinterSettings.LastPage := ToPage;
QuickRep.PrinterSettings.Copies := Copies;
QuickRep.PrinterSettings.PrinterIndex := Printer.PrinterIndex;
QuickRep.PrinterSettings.ApplySettings(QuickRep.Printer);
end;
end;
The problem comes from the Printer object. Before the Execute call,
Printer.PrintIndex is correctly set. The print dialog sets the printer to an
invalid index when you click on "ok" to print. It's why I always have this
error: "Printer index out of range".
Any Idea?
Should I need to create my own Print Dialog?
Stephane
<no direct mail please (Colin Acheson)> wrote in message
news:39384020...@newsgroups.borland.com...
If you are using Delphi3 on Windows NT, there is a problem in the D3
printers unit that can cause this type of problem. It was cured in
D5. I'm not sure about D4.
When a new printer is selected, Delphi looks for it in the printers
list. If it is found, the printer index is set to that printer.
Otherwise it adds the printer to the end of the list and uses the new
printer index. However with certain network printers on NT, Delphi
was not detecting them in the list and thus adding them again at the
end of the list and returning an invalid index.
To compare the selected printer with those in the list, Delphi 3 used
the following function. It is at approx. line 411 of Printers.pas:
function TPrinterDevice.IsEqual(ADriver, ADevice, APort: PChar):
Boolean;
begin
Result := (Device = ADevice) and (Port = APort);
end;
Try replacing this with the Delphi 5 equivalent, which is:
Result := (Device = ADevice) and ((Port = '') or (Port = APort));
Also note there is a memory leak in the D3 printers unit.
Before the last line "Inherited Destroy;" in TPrinter.Destroy, insert
the following:
if DeviceMode <> 0 then
begin
GlobalUnlock(DeviceMode);
GlobalFree(DeviceMode);
DeviceMode := 0;
end;
Regards,
Colin Acheson
On Mon, 5 Jun 2000 12:32:48 -0400, "Stephane Veillette"
<veill...@biotonix.com> wrote:
>I got a new bug.
<snip>
This way you will tell Delphi exclusively that you want to use the global
variable printer from the printers unit.
I remember I had a problem similar to yours and I think that this change
solve it.
Regards,
Stefan
"Stephane Veillette" <veill...@biotonix.com> wrote in message
news:8hgkjc$f1...@bornews.borland.com...
> I got a new bug.
>
> It's working fine with one program (OCX) but not in the other, with the
same
> code for printing.
>
> here's the code:
>
> with PrintDialog1 do
> begin
> PrintDialog1.FromPage := 1;
> PrintDialog1.ToPage := QuickRep.PageNumber;
> PrintDialog1.MaxPage := QuickRep.PageNumber;
>
> if Execute = true then
> begin
> QuickRep.PrinterSettings.FirstPage := FromPage;
> QuickRep.PrinterSettings.LastPage := ToPage;
> QuickRep.PrinterSettings.Copies := Copies;
>
> QuickRep.PrinterSettings.PrinterIndex := Printer.PrinterIndex;
> QuickRep.PrinterSettings.ApplySettings(QuickRep.Printer);
> end;
> end;
>
> The problem comes from the Printer object. Before the Execute call,
> Printer.PrintIndex is correctly set. The print dialog sets the printer to
an
> invalid index when you click on "ok" to print. It's why I always have
this
> error: "Printer index out of range".
>
> Any Idea?
>
> Should I need to create my own Print Dialog?
>
> Stephane
>
>
>
> <no direct mail please (Colin Acheson)> wrote in message
> news:39384020...@newsgroups.borland.com...
> > Thanks, Stephane and Jorrit. I will put the "ApplySettings" line in
> > my code too as a precaution.
> >
> > Regards,
> > Colin Acheson
> >
I already tried this without success.
Everything is ok now. I just create my own PrintDialog. It's the best
solution :)
Thanks to you and Colin
Regards,
Stephane
Stefan Buynov <bou...@yahoo.com> wrote in message
news:8hi765$31...@bornews.borland.com...
It does not work.
in delphi 3 and its quickreport
In article <3934e0b9...@newsgroups.borland.com>,
(no direct mail please) (Colin Acheson) wrote:
> If you are selecting a valid printer and assigning a valid printer
> index it should always work. However there is a problem with Delphi
> 3 on Windows NT with certain network printers. We had a discussion
> about it here some time back.
>
> There is a bug in the D3 printers unit where, when you select another
> printer, it sometimes does not return the chosen printer's correct
> index. Instead it adds that printers name again to the end of the
> printer list and returns an invalid index.
>
> The error is at approx. line 411 of Printers.pas in the following
> function:
>
> function TPrinterDevice.IsEqual(ADriver, ADevice, APort: PChar):
> Boolean;
>
> The function is a one-liner. In Delphi 3, it is:
>
> Result := (Device = ADevice) and (Port = APort);
>
> This should be replaced with the Delphi 5 equivalent, which is:
>
> Result := (Device = ADevice) and ((Port = '') or (Port = APort));
>
> Regards,
> Colin Acheson
>
> On Tue, 30 May 2000 16:04:42 -0400, "Stephane Veillette"
> <veill...@biotonix.com> wrote:
>
> >> MyReport.PrinterSettings.PrinterIndex := Printer.PrinterIndex;
> >
> >It doesn't work. I always got the same error "printer out of range".
> >
> >Any Idea?
> >
> >Stephane
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.