📄 quickrep.htm
字号:
<!-- This document was created with HomeSite v2.5 -->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>UDDF - Quick Report</TITLE>
<META NAME="Description" CONTENT="QuickReport section of the Delphi Developers FAQ" >
<META NAME="KeyWords" CONTENT="" >
</HEAD>
<BODY>
<BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#ffffff">
<CENTER>
<IMG SRC="../images/uddf.jpg"> </CENTER>
<P><HR></P>
<FONT FACE="Arial Black" SIZE=7 COLOR="#ff0000"><P ALIGN="CENTER">Quick Report</FONT> </P>
<P><H1><A NAME="quickrep0">QuickReports FONT Problems</P></A></H1>
<P><I>From: max@newlook.co.nz (Max Nilson)</I></P>
<PRE>artemik@ix.netcom.com (Bill Artemik) wrote:
I'm using Delphi 2.0 and QuickReports 1.1
>I created a VERY complex (graphically, anyway) report and just found
>out that ALTHOUGH it previews fine in design mode, does NOT display or
>print correctly in runtime. The error appears to be that I'm running
>with LARGE fonts in Windows 95! What a crock!
</PRE>
I too was getting this problem _very_ seriously, but only when printing
from Win 95 to the office HP 4M, or when viewing the report under NT
4.0. The _exact_ same application when run under NT 3.51 SP5 worked
perfectly.<p>
I had seen discussion of one other bug in the NT 4.0 GDI code, so I
wasn't suprised when the above test showed that there seemed to be
another. I looked very closely at the QuickReports code and noticed that
the primary text output routine alters its ouput font for every field.
Its does this via the following code segment in TQRCustomControl.Print: <P>
<HR><PRE>
QRPrinter.Canvas.Font:=Font;
QRPrinter.Canvas.Font.size:=trunc(abs(parentreport.xpos(font.size)));
QRPrinter.Canvas.brush.Color:=Color;
</PRE><HR>
Now those of us who have spent far too much time reading the VCL will
know that the VCL maintains a resource cache via a handle manager in
Graphics.pas, and that this attempts to lower the number of Windows
resources allocated by using a reference counted approach to reusing old
resource handles. The code above manages to circumvent this most
excellently! Every time the printers canvas is set to the fields font,
thus lowering the printer's old font resource count to zero and
releasing it, and then scaling the fonts size to match the printer
metrics, thus requiring a new font resource to be allocated.<P>
The upshot of all this is that _every_ field of the report was being
drawn using a newly alocated font resource, and probably driving the
meta file recorder into spasms trying to keep track of all this choping
and changing of font resources.<P>
A quick hack where by I created a non printing label of the same size as
the scaled printer font, thereby keeping the resource cached, made the
bug go away! This proved that there is some sort of problem with the NT
4.0 ehnanced meta file recorder and too many font changes.<P>
A better hack has been introduced into QuickReports as follows:<P>
<HR><PRE>
// MRN Save the printer font while setting new font
SaveFont := TFont.Create;
SaveFont.Assign(QRPrinter.Canvas.Font);
QRPrinter.Canvas.Font:=Font;
QRPrinter.Canvas.Font.size:=trunc(abs(parentreport.xpos(font.size)));
QRPrinter.Canvas.brush.Color:=Color;
// MRN Free the saved printer font. Its done its work now.
SaveFont.Free;
SaveFont := nil;
</PRE><HR>
This manages to ensure that the printer font is reused if the same font
is selected into the printer canvas. This works perfectly and produces
correct reports on NT 4.0. By some strange coincidence 8-) this also
stopped the wierd bold, out sized fonts being printed under Win95.<P>
So if you have a registered version of QuickReports thaen you simply
make this patch and things will run faster, smother and no more font
corruptions will occur due to the limitations of the enhanced meta file
code and the GDI.<P>
<H1><A NAME="quickrep1">Preview Form Caption</A></H1>
<I>Bruno Sonnino [sonnino@netmogi.com.br]</I><P>
You can set QRPrinter PreviewCaption to your caption like this:
<HR><PRE>
QRPrinter.PreviewCaption := 'My Caption';
</PRE><HR>
QRPrinter is a global variable defined in Quickrep.pas
<P><H1><A NAME="quickrep2">QuickReports on different paper sizes</P></A></H1>
<P><I>From: cannibal@bigfoot.com</I></P>
Hi!
Have you looked at the TPrinter-object? <br>
You can set the printer you want to use with the Printer.PrinterIndex.<BR>
For example:<BR>
<HR><PRE>
Printer.PrinterIndex:=0; Sets the first printer you have installed
Printer.PrinterIndex:=-1; Sets the printer to the default printer
</PRE><HR>
Observe! That this function don't make an global change to your system,
it's just for the time being.<p>
<HR SIZE="6" color="#00FF00">
<FONT SIZE="2">
<a href="mailto:rdb@ktibv.nl">Please email me</a> and tell me if you liked this page.<BR>
<SCRIPT LANGUAGE="JavaScript">
<!--
document.write("Last modified " + document.lastModified);
// -->
</SCRIPT><P>
<TABLE BORDER=0 ALIGN="CENTER">
<TR>
<TD>This page has been created with </TD>
<TD> <A HREF="http://www.dexnet.com./homesite.html"><IMG SRC="../images/hs25ani.gif" WIDTH=88 HEIGHT=31 BORDER=0 ALT="HomeSite 2.5b">
</A></TD>
</TR>
</TABLE>
</FONT>
</BODY>
</HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -