Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - Printing Report Control embedded in a Dialog
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Printing Report Control embedded in a Dialog

 Post Reply Post Reply
Author
Message
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Topic: Printing Report Control embedded in a Dialog
    Posted: 25 March 2009 at 3:14pm
Does anyone know if v. 13 supports printing the list report when the report control is embedded in a dialog?

From a view, of course, printing works fine (except the squished columns when your list has a lot of columns). I have an older version, 10.4, and it doesn't appear to have the capability. I nearly have it working, but the contents appear microscopic in the printout.  If v. 13 supports this, then I can put away my magnifying glass.
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2009 at 10:43pm
Consider attached sample with Calendar inside dialog - it allow to print using 2 helper files - DialgoPrintHelper.cpp and .h
Code OnFilePrint - inside CalendarOnDialogDlg.cpp
 
 
 
Back to Top
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Posted: 25 March 2009 at 11:43pm
Thank you mdoubson. 

It was nice to get a reply so quickly. I solved my microscopic print. I liked your solution of the print helper though. Very good! My fix was much more of a kludge. I tried to retain as much of the original report print code as possible. I reset the print mode, and rect info in the derived report control class:

class CReportForDialog : public CXTPReportControl

void CReportForDialog::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
    if (!pDC || !pInfo)
        return;

    UINT nPage = pInfo->m_nCurPage;
    ASSERT(nPage <= (UINT)m_aPageStart.GetSize());
    UINT nIndex = m_aPageStart[nPage-1];

// magic
    // Set the page map mode units, and setup margin
    pDC->SetMapMode(MM_ANISOTROPIC);
    pDC->SetWindowExt(100, 100);
    pDC->SetViewportExt(pDC->GetDeviceCaps(LOGPIXELSX), pDC->GetDeviceCaps(LOGPIXELSY));

    pInfo->m_rectDraw.SetRect(0, 0, pDC->GetDeviceCaps(HORZRES), pDC->GetDeviceCaps(VERTRES));
    pDC->DPtoLP(&pInfo->m_rectDraw);

    if (m_pPrintOptions)
    {
        CRect rcMargins = m_pPrintOptions->GetMarginsLP(pDC);
        pInfo->m_rectDraw.DeflateRect(rcMargins);
    }

// end magic

    // print as much as possible in the current page.

    nIndex = PrintPage(pDC, pInfo, pInfo->m_rectDraw, nIndex);

    // update pagination information for page just printed
    if (nPage == (UINT)m_aPageStart.GetSize())
    {
        m_aPageStart.Add(nIndex);
    }
    else
    {
        ASSERT(nPage < (UINT)m_aPageStart.GetSize());
        m_aPageStart[nPage] = nIndex;
    }
}
Back to Top
zaksoft View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 June 2003
Location: Italy
Status: Offline
Points: 162
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaksoft Quote  Post ReplyReply Direct Link To This Post Posted: 26 March 2009 at 2:06am
I've found the attached sample helpfully! Thancs, It's what I was searching for.. 2 questions..
 
1) on OnFileCaptionbarlayout() m_wndCalendarCaptionBar.UseOneLine(!m_wndCalendarCaptionBar.IsUseOneLine()) in undefined... Do I miss something ?

2) Algae reports a fix for printing withinh CReportForDialog, again I've missed something ?

 
And since maybe my lucky day... We work with spa center and normally they work with weeks r weekend... Is there any way to show 2 or 3 days (and mainly print them together) without setting all 7 days ?.
 
Normally people arrive at friday evening and get reservations for late friday, saturday and sunday and take a list of tratment. The problem using full week presentation is that columns are narrow (an half empty) so not all information are printed.
 
Thank you.
VS2008 SP1 - VS2010 SP1 - VS2012 - MFC MBCS Statically linked
XTP 15.3.1 Static Link
---------------------------------------------------------
Davide Zaccanti - ZakSoft - www.zaksoft.com
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 26 March 2009 at 9:46am
Back to Top
zaksoft View Drop Down
Senior Member
Senior Member
Avatar

Joined: 05 June 2003
Location: Italy
Status: Offline
Points: 162
Post Options Post Options   Thanks (0) Thanks(0)   Quote zaksoft Quote  Post ReplyReply Direct Link To This Post Posted: 28 March 2009 at 2:54pm
Thank you, I'll try to set working days as you suggest.
 
2 more questions:
 
1) I've read about next version due in mid-summer, you wrote about 13.1 soon.. 2 different releases ? ( this because in the calendarondialog sample in rar the timeline check box is correct, building with 13.0 is a radio button)
 
2) It is possible to insert in the wish list for planner in week mode to skip all days without any appointment ? this will solve many problems related to narrow columns.
 
Thank you again for your support.
 
 
VS2008 SP1 - VS2010 SP1 - VS2012 - MFC MBCS Statically linked
XTP 15.3.1 Static Link
---------------------------------------------------------
Davide Zaccanti - ZakSoft - www.zaksoft.com
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 28 March 2009 at 4:03pm
Hi, 13.1 is official version which suppose to go in May-June. I am ready to demonstrate now many coming features and fixes in beta-version or static app build with new code as I am interested in feedback from all or you.
 
I think what it will be possible to introduce compact multi-column week mode which can have dynamic column width (with 0 if no events) but it will means what calendars for different weeks can have different number of visual columns. It also means that we should introduce view-only mode as if you will hide some columns because no events - you can't add new events or modify existed events in such mode. Too restricted? What's about current scheme with resizable grid columns? We can have some predifne minimum width so user will not loose some day of week but screen space can be use better then now.
 
Of cource all existed mode will be as now and set as defaults.
 
By the way - I found and fix some typo bug (used OR instead of AND in some condition) which prevent action on left datepicker button click if current month is February. Current updates in static demo apps had this fix:
 
Back to Top
securigy View Drop Down
Groupie
Groupie


Joined: 23 November 2007
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote securigy Quote  Post ReplyReply Direct Link To This Post Posted: 31 March 2009 at 6:36pm
so how do you print the Report Control that is embedded in the dialog? Where can I get the sample code?
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2009 at 10:25am
There are many samples in CodeProject about printing without Doc-View acrchitecture - e.g. in Dialog. Look please. There is CJ sample with Calendar embedded in dialog print - https://forum.codejock.com/uploads/temp/20090325_224348_CalendarOnDialo.rar
Back to Top
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2009 at 2:42pm
Securigy - if you'd like, I can post the ReportControl class I developed. It includes most of the features of ReportView printing. Not as universal as the print helper class that is in this thread.


Back to Top
securigy View Drop Down
Groupie
Groupie


Joined: 23 November 2007
Status: Offline
Points: 41
Post Options Post Options   Thanks (0) Thanks(0)   Quote securigy Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2009 at 4:02pm
I'd appreciate that. I am at the stage where I cannot redo my ReportControl into the one that is derived from ReportView without major surgery...
Back to Top
Algae View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 January 2007
Location: United States
Status: Offline
Points: 217
Post Options Post Options   Thanks (0) Thanks(0)   Quote Algae Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2009 at 9:37pm
Ok, this should help you out:

uploads/20090406_213647_ReportForDialog.zip
Back to Top
mdoubson View Drop Down
Senior Member
Senior Member
Avatar

Joined: 17 November 2008
Status: Offline
Points: 1705
Post Options Post Options   Thanks (0) Thanks(0)   Quote mdoubson Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2009 at 10:42pm
Wrong link - this is proper one: https://forum.codejock.com/uploads/20090406_213647_ReportForDialog.zip
 
This is ONLY printing (no print preview) support - functions from XTPReportView copied into derived ReportControl.
 
Approach with helper I described before also have no print preview and easy to use - add 2 files and couple lines in your own code to call print when needed
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.