 |
|
|
 |
|
 |
Hello, what am I doing wrong? I got 'WTL::CIconT' : template class has already been defined error during compilation
|
| Sign In·View Thread·PermaLink | 1.40/5 (4 votes) |
|
|
|
 |
|
 |
Hi,
I ran into a bug in SetRange(...) and probably elsewhere in the MiniCalendarCtrl code. It is silently assumed that given times are always integral days (hours==0 && minutes==0 && seconds==0). If this is not the case, the behaviour is not as expected.
I suggest the following fix, applying an explicit round to the time values that are passed as parameters:
void CMiniCalendarCtrl::SetRange(const COleDateTime& dateAnchor, const COleDateTime& dateSelect) { ATLASSERT( dateAnchor.GetStatus()==COleDateTime::valid ); ATLASSERT( dateSelect.GetStatus()==COleDateTime::valid ); m_dtAnchor = floor(dateAnchor); m_dtSelect = floor(dateSelect); NotifySelChanged(); Invalidate(); }
Regards, V.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Given that the control is a calendar control (ie. deals only with dates), date-times are used internally with the time part always set to 00:00:00. Any method that violates this constraint will introduce a bug.
Also, the SetRange(...) method doesn't exist in the supplied code. You suggested it as an enhancement, remember?! Check your post.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
I'm reusing the same instance of the Ctrl for multiple purposes. When switching from one context to another, I would like to force the Ctrl to update the special days.
Therefore I added the following public method:
void CMiniCalendarCtrl::UpdateSpecialDays() { NotifyGetSpecialDays(); }
Is this a consistent extension or are there potential problems with triggering the Special Days message this way? Is there a better way to inject new special days? V.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Your suggestion is exactly the right thing to do. 
By design, the control only caches enough state to support the view. It is the clients responsibility to track special days beyond the range of months displayed.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Hi,
I like the Ctrl very much, but there seems to be a minor issue with calling ResetRange(). m_dtAnchor is invalidated, but it is then used in a comparison operation in NotifySelChanged(). This triggers a Debug assertion, comparison of invalid dates is not allowed.
I am calling ResetRange() even when the user has not yet made any selection. Maybe this is part of the problem?
Would you like to provide a fix? V.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Its not your call to ResetRange() thats the problem - its my bug
I'll put a fix up soon but for those that can't wait, in NotifySelChanged change the line:
if (m_bMultiSelEnabled) to:
if (m_bMultiSelEnabled && m_dtAnchor.GetStatus() == COleDateTime::valid)
Thanks for the feedback.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
 |
Tony, it is nice to see that you are still interested in your own code. 
While you are at it, preparing an update: I have another question/suggestion regarding CMiniCalendarCtrl::ResetRange(). What is the intended semantics of this method? From the name I would infer that a call to ResetRange actually resets the Ctrl to its pre-user-interaction state. But this is not the case, even after calling ResetRange() there is still a selection visible in the Ctrl.
To achieve clearance of the entire selection, I extended the method as follows:
BOOL CMiniCalendarCtrl::ResetRange() { if (m_dtAnchor.GetStatus() == COleDateTime::valid) { m_dtAnchor.SetStatus(COleDateTime::invalid); m_dtSelect.SetStatus(COleDateTime::invalid); NotifySelChanged();
Invalidate(); return TRUE; } m_dtAnchor.SetStatus(COleDateTime::invalid); m_dtSelect.SetStatus(COleDateTime::invalid); return FALSE; }
If this is not what ResetRange() was meant to do, then what is it? ResetRange() is called twice from inside your own code, in CMiniCalendarCtrl::OnLButtonDown(UINT nFlags, CPoint point) and in CMiniCalendarCtrl::ApplyStyle(DWORD dwStyle). I'm not sure if my changes are consistent with your use of the method in these places. Some quick testing suggests that they are.
Moreover, I added another public method that allows to prepare the range with some default selection before the user is displayed the Ctrl (or even change selection on the fly):
void CMiniCalendarCtrl::SetRange(const COleDateTime& dateAnchor, const COleDateTime& dateSelect) { ATLASSERT( dateAnchor.GetStatus()==COleDateTime::valid ); ATLASSERT( dateSelect.GetStatus()==COleDateTime::valid ); m_dtAnchor = dateAnchor; m_dtSelect = dateSelect; NotifySelChanged(); Invalidate(); }
Just for review or as a suggestion... Thanks a lot! Volker
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
 |
Hello
I have been writing an ATL control pretty much like this based on the Month Calendar common control.
Didn't get as far as you have but have code for highlighting (making bold) / unhighlighting days in month. and possibly some other things - would need to review yours more. I am happy to share code - just ask.
I would be able to review much quicker if you had created a VC6 project! So I will see if I can get going in my VC6 environment.
Angus Comber angus@iteloffice.com
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
 |
Compared to the comctl calendar this one is a ten. Thanks!
Hans J. Schroeder - Microlog GmbH - www.microlognet.com - Home of the Cabinet Manager
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |