Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Calendar
  New Posts New Posts RSS Feed - problems printing dayview (bug?)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

problems printing dayview (bug?)

 Post Reply Post Reply
Author
Message
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Topic: problems printing dayview (bug?)
    Posted: 24 October 2008 at 6:03am
The day view will be cropped when printing.
How can i fix the problem? Any patch available?
Please see picture of print preview:



and here is the screenshot of the view (control):





Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 29 October 2008 at 5:26am
Hi,
 
Run our sample, click Page Setup and change Print Range.
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
prashant View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 February 2007
Location: India
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote prashant Quote  Post ReplyReply Direct Link To This Post Posted: 13 January 2009 at 6:51am
Hi Oleg,

In the print preview image you can see one month "Oct 2008", I wish to add 2 more months, Sept 2008 and Nov 2008. How to do that?

Is it possible?


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: 13 January 2009 at 12:04pm
Just select 2 months in DatePicker and you will have it in print
Back to Top
prashant View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 February 2007
Location: India
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote prashant Quote  Post ReplyReply Direct Link To This Post Posted: 14 January 2009 at 12:21am
Thanks for reply but what I want to achieve is:

Irrespective of days selected in calendar control, I wanted to show 3 months on date header in print preview. (Previous month, current month and next month.)
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: 14 January 2009 at 1:39am
You can't do it youself but I can add extra option in

CXTPCalendarPageSetupDialog (current logic, always 1 small calendar,

always 2 small calendars, always 3 small calendars)
  -  be in Feb release 13
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: 14 January 2009 at 2:04am

What do you want to show in the case DatePicker selection covered 5 months - now it show 1st and 5th

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: 14 January 2009 at 2:14am
I decide that if DatePicker selection covered 2 or more months - keep old logic, if 1 month or less - use bool flag - show 1 small calendar or 3 (prev, current, next month). Sound good?
Back to Top
prashant View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 February 2007
Location: India
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote prashant Quote  Post ReplyReply Direct Link To This Post Posted: 14 January 2009 at 3:01am
That really sounds great 

My opinion is, we should have logic as follows:

Case 1)
If more than one month selected then show number of months selected

Case 2)
If dates ranging for one month only then add Previous and Next month alongwith current month

Another Idea:

Give option to user (Check box in Calendar page setup)
"Display Next and Previous month"
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: 14 January 2009 at 3:06am
see result
Back to Top
prashant View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 February 2007
Location: India
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote prashant Quote  Post ReplyReply Direct Link To This Post Posted: 14 January 2009 at 3:19am
See Result??

I didn't understand..please explain.
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: 14 January 2009 at 3:22am
uploads/20090115_113916_CalendarUpdates.rarI mean see the snapshot in my previous note - it already go in release 13
Default - 3 (only for 1 month or less selection) other case - old logic
Back to Top
prashant View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 February 2007
Location: India
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote prashant Quote  Post ReplyReply Direct Link To This Post Posted: 14 January 2009 at 3:31am
Ok great, Nice work, thanks :)
When shall I expect release 13?

What you have added? Whether you gave option to user? or by default you are showing Next , Current and Previous month?

Thanks again.
Back to Top
prashant View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 February 2007
Location: India
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote prashant Quote  Post ReplyReply Direct Link To This Post Posted: 15 January 2009 at 8:27am
Mark,

Can you please send me modified files for Calendar Print Preview issue?

I already mailed you / Oleg at support@codejock.com

Thanks.
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: 15 January 2009 at 11:41am
uploads/20090115_122129_Resource.rar
 
Look in one of previous the post in the begining of post - I attached files there
You need update files form CalendarUpdates.rar into Source\Calendar
from Resource.rar - resource.h going  to Source\Calendar
Resource.rc -  into Source\Calendar\res
 
Back to Top
prashant View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 February 2007
Location: India
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote prashant Quote  Post ReplyReply Direct Link To This Post Posted: 16 January 2009 at 1:35am
Hi Mark,

Code is ok. Just reverse the display sequence to:

( Previous - Current - Next )     i.e. Dec - Jan - Feb

Current sequence is:-
( Next  - Current - Previous )   i.e. Feb - Jan - Dec

Also as discussed try to add "Page Setup" button on Print preview Toolbar.
(Same as Outlook), please see attached image:


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: 16 January 2009 at 10:25am
I implemented RTL - NonRTL 3 small calendars in Page header function - this is updated code:

void CXTPCalendarControlView::DrawDateHeader(BOOL bCalculate, CDC* pDC,

CXTPCalendarControlViewPrintOptions* pOptions,

CRect& rrcHeader)

{

COleDateTime dtYearMonth1, dtYearMonth2;

CString strHeader1, strHeader2, strHeaderWeekDay;

int nMonths = _GetDateHeaderMonths(dtYearMonth1, dtYearMonth2, strHeader1, strHeader2, strHeaderWeekDay);

if (!strHeader2.IsEmpty())

strHeader1 += _T(" -");

CRect rcCalendar1 = rrcHeader;

CRect rcCalendar2(0, 0, 0, 0);

CRect rcCalendar3(0, 0, 0, 0);

BOOL bRTL = FALSE;

if (GetCalendarCtrl().GetExStyle() & WS_EX_LAYOUTRTL)

bRTL = TRUE;

int iYear = dtYearMonth1.GetYear();

int iMonth = dtYearMonth1.GetMonth();

if (nMonths == 1 && pOptions->m_b3SmallCal)

{

if (bRTL)

{

if (iMonth > 1)

iMonth--;

else

{

iMonth = 12;

iYear--;

}

dtYearMonth1.SetDateTime(iYear, iMonth, 1,0,0,0);

}

else

{

if (iMonth < 12)

iMonth++;

else

{

iMonth = 1;

iYear++;

}

dtYearMonth1.SetDateTime(iYear, iMonth, 1,0,0,0);

}

}

_DrawDateHeaderCalendar(TRUE, pDC, pOptions, dtYearMonth1, rcCalendar1);

int nCalendar1XPos = rrcHeader.right - rcCalendar1.Width() * 11/10;

int nCalendar2XPos = nCalendar1XPos;

CFont fntDateHeader;

VERIFY( fntDateHeader.CreateFontIndirect(&pOptions->m_lfDateHeaderFont) );

CXTPFontDC fntDC(pDC, &fntDateHeader);

CSize sizeText = pDC->GetTextExtent(strHeader1);

CFont fntDateHeaderWeekDay;

VERIFY( fntDateHeaderWeekDay.CreateFontIndirect(&pOptions->m_lfDateHeaderWeekDayFont) );

fntDC.SetFont(&fntDateHeaderWeekDay);

CSize sizeTextWD = pDC->GetTextExtent(_T("WD"), 2);

int nDatesCaptionHeight = sizeText.cy * 225/100 + sizeTextWD.cy * 125/100;

int nMaxHeight = max(rcCalendar1.Height() * 11/10, nDatesCaptionHeight);

rrcHeader.bottom = rrcHeader.top + nMaxHeight;

int nCalendarYPos = rrcHeader.top + nMaxHeight/2 - rcCalendar1.Height() / 2;

MoveRectToXY(rcCalendar1, nCalendar1XPos, nCalendarYPos);

if (bCalculate)

return;

//===========================================================================

COLORREF clrPrev = pDC->SetTextColor(0);

int nBkModePrev = pDC->SetBkMode(TRANSPARENT);

//---------------------------------------------------------------------------

if (nMonths > 1)

{

rcCalendar2 = rcCalendar1;

nCalendar2XPos = nCalendar1XPos - rcCalendar1.Width() * 11 / 10;

MoveRectToXY(rcCalendar1, nCalendar2XPos, nCalendarYPos);

}

if (!m_pPrintOptions->m_bBlackWhitePrinting)

pDC->FillSolidRect(&rrcHeader, RGB(229, 229, 229));

pDC->Draw3dRect(&rrcHeader, 0, 0);

_DrawDateHeaderCalendar(FALSE, pDC, pOptions, dtYearMonth1, rcCalendar1);

if (nMonths > 1)

_DrawDateHeaderCalendar(FALSE, pDC, pOptions, dtYearMonth2, rcCalendar2);

if (nMonths == 1 && pOptions->m_b3SmallCal)

{

rcCalendar2 = rcCalendar1;

nCalendar2XPos = nCalendar1XPos - rcCalendar1.Width() * 11 / 10;

MoveRectToXY(rcCalendar2, nCalendar2XPos, nCalendarYPos);

if (bRTL)

{

if (iMonth < 12)

iMonth++;

else

{

iMonth = 1;

iYear++;

}

dtYearMonth1.SetDateTime(iYear, iMonth, 1,0,0,0);

}

else

{

if (iMonth > 1)

iMonth--;

else

{

iMonth = 12;

iYear--;

}

dtYearMonth1.SetDateTime(iYear, iMonth, 1,0,0,0);

}

_DrawDateHeaderCalendar(FALSE, pDC, pOptions, dtYearMonth1, rcCalendar2);

rcCalendar3 = rcCalendar2;

nCalendar2XPos = nCalendar2XPos - rcCalendar2.Width() * 11 / 10;

MoveRectToXY(rcCalendar3, nCalendar2XPos, nCalendarYPos);

if (bRTL)

{

if (iMonth < 12)

iMonth++;

else

{

iMonth = 1;

iYear++;

}

dtYearMonth1.SetDateTime(iYear, iMonth, 1,0,0,0);

}

else

{

if (iMonth > 1)

iMonth--;

else

{

iMonth = 12;

iYear--;

}

dtYearMonth1.SetDateTime(iYear, iMonth, 1,0,0,0);

}

_DrawDateHeaderCalendar(FALSE, pDC, pOptions, dtYearMonth1, rcCalendar3);

}

CRect rcHeader1(0, 0, 0, 0);

CRect rcHeader2(0, 0, 0, 0);

CRect rcHeader3(0, 0, 0, 0);

rcHeader1 = rrcHeader;

rcHeader1.DeflateRect(10, 5, 10, 5);

rcHeader1.right = nCalendar2XPos - 20;

rcHeader2 = rcHeader1;

fntDC.SetFont(&fntDateHeader);

UINT uDrawFlags = DT_TOP | DT_LEFT | DT_WORDBREAK | DT_NOPREFIX;

int nHeight1 = pDC->DrawText(strHeader1, &rcHeader1, uDrawFlags);

if (!strHeader2.IsEmpty())

{

rcHeader2.top += nHeight1 + sizeText.cy / 4;

if (rcHeader2.top < rcHeader2.bottom)

{

pDC->DrawText(strHeader2, &rcHeader2, uDrawFlags);

}

}

if (!strHeaderWeekDay.IsEmpty())

{

fntDC.SetFont(&fntDateHeaderWeekDay);

rcHeader3 = rcHeader2;

rcHeader3.top += nHeight1 + sizeTextWD.cy / 5;

if (rcHeader3.top < rcHeader3.bottom)

{

pDC->DrawText(strHeaderWeekDay, &rcHeader3, uDrawFlags);

}

}

//---------------------------------------------------------------------------

pDC->SetTextColor(clrPrev);

pDC->SetBkMode(nBkModePrev);

}

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: 16 January 2009 at 10:26am
It means: in NonRTL mode Dec, Jan, Feb order,
in RTL - Feb, Jan, Dec
 
Back to Top
prashant View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 February 2007
Location: India
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote prashant Quote  Post ReplyReply Direct Link To This Post Posted: 19 January 2009 at 5:43am
Replaced my code, tested.

Working very Fine :)

Also following bug got resolved:

https://forum.codejock.com/forum_posts.asp?TID=13189&KW=

Thanks

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: 19 January 2009 at 8:34am

OK - put same conclusion in parallel post https://forum.codejock.com/forum_posts.asp?TID=13189&KW

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.219 seconds.