Page 1 of 1

TRVPrint

Posted: Sun Apr 28, 2013 7:21 pm
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

Posted: Sun Apr 28, 2013 7:47 pm
by Sergey Tkachenko
1. What version of TRichView do you use?
2. Can you send me a simple project reproducing the problems? To richviewgmailcom

Posted: Mon Apr 29, 2013 5:30 pm
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.

Posted: Tue Apr 30, 2013 3:34 pm
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.

Posted: Tue Apr 30, 2013 5:40 pm
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.

Posted: Thu May 02, 2013 8:04 pm
by Sergey Tkachenko
Please send a sample code showing the error with the event assignment to richviewgmailcom

Posted: Thu May 02, 2013 9:26 pm
by gdenny
The sample code is already in this post.

Posted: Thu May 02, 2013 9:36 pm
by gdenny
But I emailed it anyway. Thanks.

Posted: Tue May 07, 2013 10:21 pm
by gdenny
I have not heard back. Did you get my email? Thanks

Posted: Wed May 08, 2013 3:09 pm
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)

Posted: Thu May 09, 2013 2:15 pm
by gdenny
That worked like a charm. Thank you so much.