Print Page | Close Window

Fatal CalendarTheme bug and ?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=15370
Printed Date: 23 November 2024 at 11:10am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Fatal CalendarTheme bug and ?
Posted By: Algae
Subject: Fatal CalendarTheme bug and ?
Date Posted: 14 October 2009 at 8:29pm
XTPCalendarTheme.cpp Version 13.1 with additional fixes/enhancements

Fatal bug around line 3390 in method Draw. If values were 0 would divide by or divide into 0. I don't know if my fix is legit, but it keeps the thing from crashing.

void CXTPCalendarTheme::CTODayViewDayGroup::Draw(CCmdTarget* pObject, CDC* pDC)

// original

            if (pViewEvent->IsMultidayEvent() || pViewEvent->GetEvent()->IsAllDayEvent())
            {
                CRect rcEvent(pViewEvent->GetEventRect());
                nVisAllDayEvents = nAllDayHeight / rcEvent.Height();
                nAllDayShift = max(iCurTopRow - iTopRow, 0);
                nAllDayShift = min(nAllDayShift, nEventsCount - nVisAllDayEvents);
                nAllDayShift = max(nAllDayShift, 0);
            }

// for a quick fix I added a check for values nAllDayHeight and rcEvent.Height()

                CRect rcEvent(pViewEvent->GetEventRect());
                if (nAllDayHeight && rcEvent.Height())
                {
                    nVisAllDayEvents = nAllDayHeight / rcEvent.Height();
                    nAllDayShift = max(iCurTopRow - iTopRow, 0);
                    nAllDayShift = min(nAllDayShift, nEventsCount - nVisAllDayEvents);
                    nAllDayShift = max(nAllDayShift, 0);
                }

Now my question:

In addition, I'm experiencing an odd problem which so far has eluded me.

I use a modeless property sheet to display Event data. However, when I do, the CalendarControl will not update it's display properly.

I can move the scroll bar and date selector controls normally and all other aspects of the program take focus properly. Toolbars, tips, menus, other dialogs all work as they should. But - the calendar display itself will not update! For instance scrolling the view up or down is not reflected until the property sheet is closed. The same goes for the view type. Go from work week to month view and nothing happens... until the property sheet is closed. To make matters worse I can open other modeless property sheets derived from the same exact base class and everything works perfectly. It only happens to the property sheet when used to display an Event.

Any thoughts on how to make the calendar control keep itself up-to-date? This really has me perplexed.

Many thanks if anyone can offer some insight into this.





Replies:
Posted By: mdoubson
Date Posted: 15 October 2009 at 3:53pm
Did you get summer version of MFC Calendar source updates?
 
https://forum.codejock.com/uploads/DemoVersion/CalendarControlMFCUpdated.rar - https://forum.codejock.com/uploads/DemoVersion/CalendarControlMFCUpdated.rar
 
Please take a look


-------------
Mark Doubson, Ph.D.


Posted By: Algae
Date Posted: 17 October 2009 at 2:54pm
Mark -

Using the code from the link you provided I was still able to duplicate the modeless dialog issue.

To see the effect:

1. run the CalendarDemo program

2. select and open an existing "recurring event" from a calendar view that has other events (so you can see the effect). It doesn't seem to matter whether it's series or occurrence. You will see that the dialog acts modelessly. A regular event will be modal so do not use one for this test.

3. In the calendar view adjust the vertical scroll bar up or down so it's in a different position. Or adjust the selected dates.  While you move the event dialog around you will see that the screen is not updated correctly, but only in the areas you have passed the dialog over!

4. Close the event dialog. The screen will now be updated properly.

I hope that this information helps.



Posted By: mdoubson
Date Posted: 17 October 2009 at 3:11pm

I recommended you a link to more recent code just to show that your fatal problem not existed more then 2 months.

Other problem you report is not related to this updates and you are the first person who report it.

What do you want - disable vertical scrollbar if modeless dialog active? Btw - activex version use Modal dialog (build-in or custom VB form).

Change dialog to be modal? Force View update?

What is the practical reason to use scrollbar during event edit (specially if you edit occurence - not a serie)?



-------------
Mark Doubson, Ph.D.


Posted By: mdoubson
Date Posted: 17 October 2009 at 4:38pm
No - I was wrong (MFC and ActiveX are similar - Modal for single events and Modeleass for recurrent ones). So my question is - should we make recurrent case also Modal?

-------------
Mark Doubson, Ph.D.


Posted By: mdoubson
Date Posted: 17 October 2009 at 6:04pm

Fixed - now MFC and build-in ActiveX event dialog work as normal modal - same as ActiveX with VB Custom Form. 



-------------
Mark Doubson, Ph.D.


Posted By: mdoubson
Date Posted: 17 October 2009 at 6:07pm
I also refresh  https://forum.codejock.com/uploads/DemoVersion/CalendarControlMFCUpdated.rar - https://forum.codejock.com/uploads/DemoVersion/CalendarControlMFCUpdated.rar
 
Please try in your case


-------------
Mark Doubson, Ph.D.


Posted By: mdoubson
Date Posted: 17 October 2009 at 6:54pm
You can also try activex case with built-in event editor (e.g. using our VB Calendar Sample) using fresh ocx - https://forum.codejock.com/uploads/BetaOCX/CalendarBeta13-2.rar - https://forum.codejock.com/uploads/BetaOCX/CalendarBeta13-2.rar

-------------
Mark Doubson, Ph.D.


Posted By: mdoubson
Date Posted: 18 October 2009 at 11:50am

You can try updated sample - https://forum.codejock.com/uploads/DemoVersion/CalendarDemoStatic.rar - https://forum.codejock.com/uploads/DemoVersion/CalendarDemoStatic.rar



-------------
Mark Doubson, Ph.D.


Posted By: Algae
Date Posted: 19 October 2009 at 5:14pm
Mark -

I believe the "all day" fatal error has been corrected.

I can confirm the recurring event dialog is no longer modeless in the demo.

However I actually wish to be able to open modeless event dialogs and that is why I asked if there was some way to update the calendar view while a modeless event dialog is open.

Is it possible?

I don't understand why the calendar view won't redraw properly when a modeless event dialog is shown.

I realize it's probably a lot harder to address than simply changing all the dialogs to modal but if you can help, it would be appreciated.


Posted By: mdoubson
Date Posted: 19 October 2009 at 5:28pm
Because you don't have real modeless dialog - you need to use Create function for modeless case (and control show it - hide it - delete it some way if you want to reuse it). That we had was just wrong case of one (small) dialog called inside main modal dialog - small dialog own DoModal enable App  Main Window after small dialog end. In modeless case you need to have smth like OnApply function which will do app and control update.

-------------
Mark Doubson, Ph.D.


Posted By: mdoubson
Date Posted: 19 October 2009 at 6:55pm

See - this is all I changed: XTPCalendarEventPropertiesDlg/cpp

//CXTPCalendarOccurSeriesChooseDlg dlg(0, XTP_IDS_CALENDAR_OCURR_SERIES_OPEN);

CXTPCalendarOccurSeriesChooseDlg dlg(this, XTP_IDS_CALENDAR_OCURR_SERIES_OPEN);



-------------
Mark Doubson, Ph.D.


Posted By: mdoubson
Date Posted: 19 October 2009 at 10:10pm
You can open an issue, attach your prototype project with modeless event editor and I can help you with it.
You need to organize 2-way communication between control and editor - to pass selected event to modify or switch editor in create new event mode if there is no selection. And OnApply editor will ask Calendar to update.


-------------
Mark Doubson, Ph.D.


Posted By: Algae
Date Posted: 20 October 2009 at 5:13pm
I'm not worried about the mechanics of setting up modeless dialogs as I already do that. Nor does my app require communication for an "apply" condition since I don't allow changes until the user OK's the dialog.

The only trouble I have is that while a modeless event dialog is displayed, the calendar view does not draw properly if the user changes the view selection (datepicker, scroll etc). As I stated initially, while all the controls work properly the view does not update. (unless you move the dialog around which repaints the view underneath it)

I was hoping that the problem could be isolated by using the modeless "recurrence" dialog to illustrate the issue. Nevertheless, if this is not the case, then I will proceed with your suggestion to open an issue and configure a calendar demo project to use a  modeless event dialog by means of the usual "create" method for modeless dialogs.


Posted By: mdoubson
Date Posted: 20 October 2009 at 5:18pm
Sure - open the issue please.
You understand from my two lines of code that we did not really have proper modeless case - it was old bug but you was the first person who found it - thanks!


-------------
Mark Doubson, Ph.D.


Posted By: Algae
Date Posted: 24 October 2009 at 2:46pm
I was unable to duplicate the issue using a modified calendar demo with a modeless event dialog. It worked fine so I determined it was something I was doing wrong in my own modeless processing loop.

I solved the problem in my application by sending the calendarctrl an invalidate(FALSE) from my modeless dialog thread. Probably not the most efficient solution but the results proved satisfactory. The control updates correctly and smoothly now.


Posted By: mdoubson
Date Posted: 24 October 2009 at 2:59pm
Very good.

-------------
Mark Doubson, Ph.D.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net