Link to home
Start Free TrialLog in
Avatar of NetGeek
NetGeek

asked on

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

Avatar of vadim_ti
vadim_ti

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;

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.
Avatar of NetGeek

ASKER

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
Avatar of NetGeek

ASKER

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
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
Avatar of NetGeek

ASKER

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

Chuck
Avatar of NetGeek

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of cqhall
cqhall

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NetGeek

ASKER

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 :=)