TRVPrint

General TRichView support forum. Please post your questions here
Post Reply
gdenny
Posts: 28
Joined: Wed Jul 22, 2009 6:46 pm

TRVPrint

Post by gdenny »

I call the same function to fill a richview, assign it to a TRVPrint that was dropped on the form at design time, and print it. The first time I call this function, everything prints correct. When I call it again, the second printout is a little different. The problem goes away when I create the TRVPrint at run time at the beginning of the function and destroy it at the end so I think it must have something to do with left overs in TRVPrint. This is acceptable as a work around except that I need an OnPagePrepaint event to print page numbers and I cannot get my code to compile with an OnPagePrepaint event created at runtime. It gives this error:

[BCC32 Error] : E2034 Cannot convert 'void (_fastcall * (_closure )(TRVPrint *,int,TCanvas *,bool,TRect &,TRect &))(TRVPrint *,int,TCanvas *,bool,TRect &,TRect &)' to 'TRVPagePrepaintEvent'

Thanks, Glenn
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

1. What version of TRichView do you use?
2. Can you send me a simple project reproducing the problems? To richviewgmailcom
gdenny
Posts: 28
Joined: Wed Jul 22, 2009 6:46 pm

Post by gdenny »

Version 12.0.4 with BCB2007. No project but here is a snippet.

From design time RVPrint on a form.

void AForm::PrintTheReport(char WhichHeader, String PrintCopyString)
{
RVPrint1->AssignSource(ReportRichViewEdit);
FillHeader(WhichHeader, PrintCopyString, 1, 1);
FillFooter(1, 1);
RVPrint1->SetHeader(HeaderRichView->RVData);
RVPrint1->SetFooter(FooterRichView->RVData);
RVPrint1->FormatPages(TRVDisplayOptions());
RVPrint1->Print("",1,0);
RVPrint1->Clear();
}

With runtime approach:
This works correctly each without the needed OnPagePrepaint event

void AForm::PrintTheReport(char WhichHeader, String PrintCopyString)
{
//create a TRVPrint object
TRVPrint* rvPrinter = new TRVPrint(this);
//set properties
rvPrinter->LeftMarginMM = 16;
rvPrinter->RightMarginMM = 16;
rvPrinter->BottomMarginMM = 20;
rvPrinter->TopMarginMM = 20;
rvPrinter->ClipMargins = false;
rvPrinter->ColorMode = rvcmPrinterColor;
rvPrinter->FixMarginsMode = rvfmmAutoCorrect;
rvPrinter->FooterYMM = 10;
rvPrinter->HeaderYMM = 10;
rvPrinter->MirrorMargins = false;
rvPrinter->PreviewCorrection = true;
rvPrinter->TransparentBackground = true;
//set event
//rvPrinter->OnPagePrepaint = RVPrinterPagePrepaint;
//print
rvPrinter->AssignSource(ReportRichViewEdit);
FillHeader(WhichHeader, PrintCopyString, 1, 1);
FillFooter(1, 1);
rvPrinter->SetHeader(HeaderRichView->RVData);
rvPrinter->SetFooter(FooterRichView->RVData);
rvPrinter->FormatPages(TRVDisplayOptions());
rvPrinter->Print("",1,0);
delete rvPrinter;
rvPrinter = 0;
}

Thanks.
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Too old version, I believe this problem is fixed (I remember fixing something like this a long time ago). Please upgrade to newer version.
gdenny
Posts: 28
Joined: Wed Jul 22, 2009 6:46 pm

Post by gdenny »

But everything else works so well and this version would also if I could make the OnPrepaint event work. I really don't mind creating and destroying the RVPrint each cycle. Before I request money for an upgrade, can you suggest something on the compile error I get when I assign that event. Thanks.
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Please send a sample code showing the error with the event assignment to richviewgmailcom
gdenny
Posts: 28
Joined: Wed Jul 22, 2009 6:46 pm

Post by gdenny »

The sample code is already in this post.
gdenny
Posts: 28
Joined: Wed Jul 22, 2009 6:46 pm

Post by gdenny »

But I emailed it anyway. Thanks.
gdenny
Posts: 28
Joined: Wed Jul 22, 2009 6:46 pm

Post by gdenny »

I have not heard back. Did you get my email? Thanks
Sergey Tkachenko
Site Admin
Posts: 17564
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

Sorry for the delay.
Add "const" to TRect parameters:

Code: Select all

void __fastcall TForm1::RVPrinterPagePrepaint(TRVPrint *Sender, int PageNo, TCanvas *Canvas, bool Preview, [color=red]const[/color] TRect &PageRect, [color=red]const[/color] TRect &PrintAreaRect)
gdenny
Posts: 28
Joined: Wed Jul 22, 2009 6:46 pm

Post by gdenny »

That worked like a charm. Thank you so much.
Post Reply