TRVPrint
TRVPrint
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
[BCC32 Error] : E2034 Cannot convert 'void (_fastcall * (_closure )(TRVPrint *,int,TCanvas *,bool,TRect &,TRect &))(TRVPrint *,int,TCanvas *,bool,TRect &,TRect &)' to 'TRVPagePrepaintEvent'
Thanks, Glenn
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
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.
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;
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.
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
-
- Site Admin
- Posts: 17559
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Sorry for the delay.
Add "const" to TRect parameters:
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)