LocalPrintDialog := TPrintDialog.Create(nil);
That was the trick I needed, as from the help a form is passed as an
argument, and I hadn't figured if it is essential.
Related question, having stuck stuff on Tprinter.canvas, what is the
simplest way to display this? ie print preview - I am guessing it means
copying stuff back to a form canvas and scaling it again (which is OK if
needed, I am already doing that to put stuff on the printer canvas from the
original form) . It would be nice to be able to do this without printing it
to check how it looks to check layout and what I changed when I copied to
the printer canvas.
(I am writing a general routine to print any of my forms, including page
controls and grids, I've decided to write my own so I can control if
required headings, the order the tabs and grids print out in and alter or
suppress some of them - I just pass in the form name and an optional list of
the component names in the order for them to print, default being all on the
form in the order the form knows them minus any buttons).
John
You can use a TPrintDialog in your pas file without a form. Declare a
TPrintDialog; you'll need Dialogs in a uses clause. I think something like:
procedure PrintSomethingInteresting;
var
LocalPrintDialog : TPrintDialog;
begin
LocalPrintDialog := TPrintDialog.Create(nil);
try
if LocalPrintDialog.Execute then
//do something interesting
finally
LocalPrintDialog.Free;
end;
end;
[EMAIL PROTECTED] on Thursday, 24 November 2005 at 2:28 a.m. +0000
wrote:
>Here is something that puzzles me, and maybe I have missed something,
>or my D5 compiler is inconsistent, or I am doing it wrong?
>
>I have a group of external procedures in a code only unit (no form) and
>to access them I just have the unit in the uses clause and then call in
>code by name eg
>
> externalproc1(arg1,arg2,arg3....)
>
>If the other unit has a form attached then I use the same uses syntax,
>but I have to call it by
>
> frmOtherform.externalproc1(arg1,arg2,arg3...)
>
>Except that I think I have also have found sometimes the compiler does
>seem to figure out where the externalproc1 is and doesn't always
>require the formname before the procedure.
>
>All I was trying to do was call some code in an external unit which
>does printing, and the only reason I have a form for that unit is that
>I plonked the printdialog on it (it doesn't have anything else on the
>form) as it seemed best to keep it with the printing code. But it made
>calling the printing routines more verbose. Is there a better way to do
>it?
>
>John
>
>
>_______________________________________________
>Delphi mailing list
>[email protected] http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi
_______________________________________________
Delphi mailing list
[email protected]
http://ns3.123.co.nz/mailman/listinfo/delphi