Solved

Problems with Delphi3/QuickReport

Posted on 2004-10-06
11
805 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ddeman not working in activex 3 92
Connection between libmysql.dll and MySQL Versions 7 87
Delphi Form ownership 4 70
CheckListBox usage 3 48
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

937 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

4 Experts available now in Live!

Get 1:1 Help Now