Fatal CalendarTheme bug and ? |
Post Reply |
Author | |
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
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. |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Did you get summer version of MFC Calendar source updates?
Please take a look
|
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
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. |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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)? |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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?
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Fixed - now MFC and build-in ActiveX event dialog work as normal modal - same as ActiveX with VB Custom Form. |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
I also refresh https://forum.codejock.com/uploads/DemoVersion/CalendarControlMFCUpdated.rar
Please try in your case
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
You can try updated sample - https://forum.codejock.com/uploads/DemoVersion/CalendarDemoStatic.rar |
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
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. |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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.
|
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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); |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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.
|
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
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. |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
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!
|
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
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. |
|
mdoubson
Senior Member Joined: 17 November 2008 Status: Offline Points: 1705 |
Post Options
Thanks(0)
|
Very good.
|
|
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 |