add header/footer to ReportControlview print ? |
Post Reply |
Author | |
unknow
Groupie Joined: 14 January 2009 Location: Belgium Status: Offline Points: 62 |
Post Options
Thanks(0)
Posted: 05 August 2009 at 5:33pm |
Hi. The Reportcontrolview demonstrated with the Reportsample demo app provides Printing and PrintPreview capabilities.
I would like to be able to add a text header and footer to this view to include current page, total page etc...
How can I do that ?
Thankx!!
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
This is supported feature - check class CXTPReportViewPrintOptions (file XTPReportView.h)
|
|
unknow
Groupie Joined: 14 January 2009 Location: Belgium Status: Offline Points: 62 |
Post Options
Thanks(0)
|
Thanks; I understand it works with formatstring features; What are the "variables" to pass to the formatstring member to insert current page, total pages, date/time etc...For example, let's say I want to display a static text as header and a variable text as footer like the date on the left and the #/pages on the right.
Can someone link me to a sample or provide the code portion?
Is it also possible to add graphical elements like lines or a rectangle around the header/footer?
Thankx!
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
This vars used in CXTPReportPageSetupDialog class so look in this class source e.g.
CReportPaneViewView use this m_pPrintOptions->GetPageHeader()->m_strFormatString = "Header text: &p from &P";
https://forum.codejock.com/uploads/DemoVersion/ReportPaneViewStatic.rar
https://forum.codejock.com/uploads/DemoVersion/PaneViewReportSource.rar 'Header text: ' and ' from '- static parts, &p and &P - dynamic parts No support for graphical elements but you can use Watermark image in print / printpreview using special flag: GetReportCtrl().SetWatermarkBitmap(_T("C:\\MyJpgFile.jpg"), 100); GetReportCtrl().SetWatermarkAlignment(xtpReportWatermarkCenter | xtpReportWatermarkVCenter | xtpReportWatermarkPreserveRatio | xtpReportWatermarkStretch); GetReportCtrl().GetPaintManager()->m_bPrintWatermark = TRUE; see http://forum.codejock.com/forum_posts.asp?TID=14922 with snapshots |
|
unknow
Groupie Joined: 14 January 2009 Location: Belgium Status: Offline Points: 62 |
Post Options
Thanks(0)
|
Wow, looks awesome, I'm going to look at these !
Where can I see all the variables available to use, CXTPReportPageSetupDialog ?
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
XTPReportView.h, XTPDrawHelpers.h |
|
unknow
Groupie Joined: 14 January 2009 Location: Belgium Status: Offline Points: 62 |
Post Options
Thanks(0)
|
I have one more concern when I look at this great sample: I see that the WHOLE printing code (including pagesetup options, paginate, header/footer customization...) has been re-done, compared to the "ReportSample" which uses the default built-in code.
This "ReportPaneView" even replaces the printing preview toolbar with a new one
So I understand I shouldn't use the default code and get all from the ReportPaneView sample ? or is this code is about to be implemented as default for next codejock release ?
Thankx!
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
You rigth in term of totally updated CXTPReportView class but it is not related to printpreview framework -
I just use COMMANDBARS PrintPreview framework which do nothing with real printpreview code except toolbar, buttons, zooming -
DoPrintPreview internally call my function CXTPReportView::OnFilePrintPreview() which do real work.
If I compile withiout COMMANDBARS and use CXTPReportView::OnFilePrintPreview()) only - everything will be the same -
only use old microsoft printpreview toolbar with only 2 pager button (Next and Prev)
void CReportPaneViewView::OnFilePrintPreview() {
#ifdef _XTP_INCLUDE_COMMANDBARSCPrintPreviewState* pState = new CPrintPreviewState; if ( !DoPrintPreview( XTP_IDD_PREVIEW_DIALOGBAR, this,RUNTIME_CLASS( CXTPPreviewView ), pState )) { delete pState; }#else CXTPReportView::OnFilePrintPreview(); #endif } This is source code - https://forum.codejock.com/uploads/DemoVersion/PaneViewReportSource.rar - build yourself both variants and compare |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
I modify sample - https://forum.codejock.com/uploads/DemoVersion/ReportPaneViewStatic.rar
you can use toolbar printpreview button (before help) to launch std framework printpreview and menu - file - printpreview to launch CJ framework printpreview
|
|
zaksoft
Senior Member Joined: 05 June 2003 Location: Italy Status: Offline Points: 162 |
Post Options
Thanks(0)
|
One problem alreade seen in other cases.
1) Open exe
2) Click Help-> Release Sort
3) Click Close
On middle of header title "Column 8" there is a vertical 2..3 pixel red line.
Tested both on Vista 32 SP2 and XP 32 SP3 at different resolution
|
|
VS2022 - MFC MBCS Statically linked
XTP 23.1 Static Link --------------------------------------------------------- Davide Zaccanti - ZakSoft - www.zaksoft.com |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
This is normal reaction - not a problem - because you use Wysiwyg mode - this red marker (end of visual page) help you properly resize columns to fit in page
You can use some handler (button, menu...) with code:
GetReportCtrl().GetPaintManager()->SetColumnWidthWYSIWYG(!GetReportCtrl().GetPaintManager()->IsColumnWidthWYSIWYG()); GetReportCtrl().RedrawControl(); and this red marker disapear. Later you can call same handler again to switch back to WYSIWYG mode
|
|
unknow
Groupie Joined: 14 January 2009 Location: Belgium Status: Offline Points: 62 |
Post Options
Thanks(0)
|
Thanks Mark for the explanation of the reportpaneview sample, I could include the improved look without efforts
Another question if you don't mind;
Using both standard printing implementation + standard page setup dialog implementation, how can I get access to the header + footer customization so I can save/load them with the opened document ?
Extra question: Is there also a way to "intercept" the header/footer at printing time in order to manage additional custom variables ?
Thanks a lot!
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Additional custom variables - only if you derive own ReportView class.
Basic custom variables - sure: you have this two strings (in CXTPReportView or your derive class like CReportPaneViewView) to store and load
GetPrintOptions()->GetPageHeader()->m_strFormatString
GetPrintOptions() ->GetPageFooter()->m_strFormatStringYou can keep in this vars enough information (and using "\n" add extra lines) |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Follow my promice - I add CXTPReportPaintManager::ShowWYSIWYGMarkers(BOOL bSet) function -
you can dynamically set it On or Off to show or hide Red End of Page WYSIWYG mode markers
|
|
zaksoft
Senior Member Joined: 05 June 2003 Location: Italy Status: Offline Points: 162 |
Post Options
Thanks(0)
|
Thank you
|
|
VS2022 - MFC MBCS Statically linked
XTP 23.1 Static Link --------------------------------------------------------- Davide Zaccanti - ZakSoft - www.zaksoft.com |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |