Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Delphi Rave Reports How do you link the CurrentPage and Pages Properties to TRVSystem Component

Posted on 2010-09-01
9
Medium Priority
?
2,360 Views
Last Modified: 2013-11-23
Using Code Based Rave Reports in Delphi, how do I display the CurrentPage Number and Total Pages in a report? I have a TRVSystem component but the CurrentPage and Pages property is linked to the TRvRenderPreview component.
0
Comment
Question by:HenryM2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 13

Expert Comment

by:aflarin
ID: 33578407
Well, the current page you can show easy:

  procedure PrintGridHeader;
  ....
    with Sender as TBaseReport do
    begin
      if CurrentPage <> 1 then // don't show page number on the first page (just for example)
        PrintCenter(IntToStr(CurrentPage), PageWidth/2);
0
 

Author Comment

by:HenryM2
ID: 33578721

I am using this line:

PrintCenter('Page ' + IntToStr(CurrentPage) + ' Of ' + IntToStr(Pages), PageWidth/2);

The compiler is happy with (CurrentPage) works but it reports  (Pages) is reported as Undeclared Identifier..


0
 
LVL 13

Expert Comment

by:aflarin
ID: 33578943
the problem is how to know amount of pages if is still printing

it seems you have to generate first, save page count into variable and then generate it again. Here is example:

procedure TForm1.Button1Click(Sender: TObject);
begin
  RvSystem1.Generate; // generates only for getting page count
  RvSystem1.Execute; // the second for preview
end;

var
  Pages: Integer;

procedure TForm1.RvSystem1AfterPrint(Sender: TObject);
begin
  Pages:= (Sender as TBaseReport).CurrentPage;
end;


procedure TForm1.RvSystem1Print(Sender: TObject);

  procedure PrintGridHeader;
  var
    iCol: Integer;
    curY: Double;
  begin
    with Sender as TBaseReport do
    begin
      if CurrentPage <> 1 then
        PrintCenter(IntToStr(CurrentPage) + IntToStr(Pages), PageWidth/2);
   ......

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:HenryM2
ID: 33579077
Yes, this is one way.  The other way I thaught about  to get the number of pages would be to take the number of rows in the StringGrid and Div it by 50 (50 lines per page) + 1.

The idea of pages, however came form the Rave Report manual.  Below, a screen print from the manual.  Is this not an option?


Rave-Report-Pages-Property.png
0
 
LVL 13

Accepted Solution

by:
aflarin earned 2000 total points
ID: 33579173
>> and Div it by 50 (50 lines per page) + 1.

It's a good idea. But you should add 1 only if count of lines > 50, 100, 150 etc
Like this:

Pages:= (StringGrid1.RowCount div 50);
if (StringGrid1.RowCount mod 50) > 0 then
  Inc(Pages);

>> Is this not an option?

I guess no, it only for showing in your controls as report status, but the report was already generated and you can't print the count of pages


0
 

Author Closing Comment

by:HenryM2
ID: 33579370
Thanks
0
 
LVL 25

Expert Comment

by:epasquier
ID: 33586326
> Pages:= (StringGrid1.RowCount div 50);
> if (StringGrid1.RowCount mod 50) > 0 then Inc(Pages);

This kind of thing is generally done in one single step :

Pages:= ( Count + NbPerPage -1 ) Div NbPerPage;

in you case :
Pages:= (StringGrid1.RowCount+49) div 50;

Open in new window

0
 
LVL 13

Expert Comment

by:aflarin
ID: 33587341
Thanks Epasquier

I suspected that it can be done in one string, but was too tired to think

0
 

Author Comment

by:HenryM2
ID: 33587409
Thanks to both of you.  Well as they say, there is many ways to skin a cat, perhaps some a bit more elegant than others, but the main thing is that my program is working very well.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

618 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