Solved

Problems with Delphi3/QuickReport

Posted on 2004-10-06
11
800 Views
Last Modified: 2008-01-09
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
NetGeek

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.

0
Comment
Question by:NetGeek
11 Comments
 
LVL 6

Expert Comment

by:vadim_ti
ID: 12237787
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
0
 
LVL 2

Expert Comment

by:cula99
ID: 12247726
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;

interface

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

type
  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
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

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

end.
0
 

Author Comment

by:NetGeek
ID: 12256751
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
NetGeek
0
 

Author Comment

by:NetGeek
ID: 12257710
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 ?
0
 
LVL 2

Expert Comment

by:cqhall
ID: 12261136
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
white
In the line above is the word white

becomes...

{\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
}

Chuck
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:NetGeek
ID: 12262869
chuck >> sounds interessting. couldn't i just add the text line for line and use selattributes on the QRMEmo ?

NetGeek

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.
0
 
LVL 2

Expert Comment

by:cqhall
ID: 12263201
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.
0
 
LVL 2

Expert Comment

by:cqhall
ID: 12263372
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.

Chuck
0
 

Author Comment

by:NetGeek
ID: 12295681
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
NetGeek
0
 
LVL 2

Accepted Solution

by:
cqhall earned 500 total points
ID: 12309153
NetGeek:

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
begin
 QuickRep1.Printer.NewPage;
end;

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).

Chuck
0
 

Author Comment

by:NetGeek
ID: 12317140
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 :=)
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video discusses moving either the default database or any database to a new volume.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now