• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 872
  • Last Modified:

Problems with Delphi3/QuickReport

Hi there,

I'm in a situation where I'm forced to used Delphi3 and QuickReport. Things are working "fine", but I have 2 major problems:

1. I have several QRSubDetailBand's with a QRMemo as the bottom component. These memo's are set to autostretch, and it works fine as long as the text put into the memo's doesn't include empty lines. When there's an empty line in the text, the following text isn't shown. IS there a way around that ?

2. I need a way to ensure that a QRSubDetailBand isn't split up, i.e. that the entire band is printed on the same page. How do i acchieve that ?

best regards

NB: As mentioned I'm FORCED to use Delphi 3 and QuickReport, so comments telling me that there are better products to use are both irrelevant and annoying, so please save them for another occasion.

1 Solution
1. QRMemo

you can delete empty lines form your QRMemo in TQRBand beforeprint event

2. I need a way to ensure that a QRSubDetailBand isn't split up, i.e. that the entire band is printed on the same page. How do i acchieve that ?

you can use LinkBand property to link your QRSubDetailBand  to another band. two of them will be printed on the same page
if you have not such band (for link) create new band with 0 height
Try something like this, it was working in delphi 4-7. With this code I was certain that my document have one detail on page where is summary band. you can modify it do do what you need.

unit Unit1;


  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, QuickRpt, QRCtrls, ExtCtrls;

  TF1QuickRep = class(TQuickRep);
  TForm1 = class(TForm)
    QuickRep1: TQuickRep;
    PageHeaderBand1: TQRBand;
    TitleBand1: TQRBand;
    ColumnHeaderBand1: TQRBand;
    DetailBand1: TQRBand;
    SummaryBand1: TQRBand;
    PageFooterBand1: TQRBand;
    QRMemo1: TQRMemo;
    ChildBand1: TQRChildBand;
    ChildBand2: TQRChildBand;
    ChildBand3: TQRChildBand;
    procedure SummaryBand1BeforePrint(Sender: TQRCustomBand;
      var PrintBand: Boolean);
    { Private declarations }
    { Public declarations }

  Form1: TForm1;


{$R *.dfm}

procedure TForm1.SummaryBand1BeforePrint(Sender: TQRCustomBand;
  var PrintBand: Boolean);
  if TF1QuickRep(QuickRep1).AvailableSpace
     <= (round(ChildBand1.Size.Height)+
         round(ChildBand3.Size.Height)) then

NetGeekAuthor Commented:
vadim_ti >> your solution to 1 won't work. I need to display the empty lines in the memo. The user has entered text in a BLOB-field, and I can't edit that text (well, I could, but then the user gets mad ;). I'm going to try inserting a space in all empty lines and then see how it behaves.

cula99 >> that looks VERY interessting, I'll have a go at that one (shouldn't all the childbandx have TF1QuickRep.Childbandx ?)

take care
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

NetGeekAuthor Commented:
hmm, I tried to replace all empty lines with spaces, and now i get all the lines printed, except the ones with a space :(. QuickReport apparently trims the lines and throws away lines wihtout any text. How the h... do i prevent this ?

cula99 >> :( QuickReport in Delphi3 doesn't understand TF1QuickRep, and the normal  TQuickRep doens't have availablespace as a property

any other ideas ?
You might try a QRRichText component and use "white" text instead of a space or blank line.  You'll need to add other symbols as indicated by the following plain and rich text versions of the same text. Incidentally, I used WordPad to create the sample rich text - don't use Word, because it adds lots of garbage.

This is a test of a white formatted word
In the line above is the word white


{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\colortbl ;\red255\green255\blue255;}
\viewkind4\uc1\pard\f0\fs20 This is a test of a white formatted word\par
\cf1 white\par
\cf0 In the line above is the word white\par

NetGeekAuthor Commented:
chuck >> sounds interessting. couldn't i just add the text line for line and use selattributes on the QRMEmo ?


I'm not really happy about the TQRMemo though. I've had situation where the component doesn't display its text in preview, but prints it out just fine.
That sounds like a cleaner way of achieving the same result - writing text with "invisible ink".

Another idea occurred to me. Experiment with control characters (<32) or extended ascii (>127) to use in the "blank" line in the standard QRmemo.  In particular, look at 255 - it shows up blank in some fonts.
I tested one of my projects that uses a QRMemo.

I inserted chr(1) through chr(31) and chr(127) through chr(255) in a QRMemo control.   Only a chr(160) looked "blank".  I inserted a line with only a chr(160) in it between lines that contained text, and it provided a "blank" line in the preview and the printout.

My QRMemo component is using "Arial" font.  Also, I'm using Delphi 7 and the latest version of Quick Reports (standard included version).  Your mileage may vary.

NetGeekAuthor Commented:
Chuck, you're an absolute star !! chr(160) did the trick :) I only tried with chr(1) to chr(31), I never thought about the extended characters ;)

If you could just find a way to keep a SubDetailBand on the the same page, I could give you the whole load of points *hint hint* ;)

take care

You might be able to do something like this in the QRSubDetail's BeforePrint event:

if QRSubDetail1.Size.Height+QuickRep1.CurrentY>QuickRep1.Page.Length then

I couldn't test this because I populate QRSubDetail1 in its BeforePrint event and the height property doesn't reflect the true (dynamic) height at that point.  If you have the same situation, then you'll need to figure out the dynamic height of the control (i.e., number of lines x line height).

NetGeekAuthor Commented:
HI Chuck,

I think you are on to something here. I populate the SubDetailBand in onBeforePrint aswell, but I didn't know about the currenty property. I should be able to figure something out using that property as you described. Thanks a bunch :=)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now