Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » CExtDateTimeWnd Collapse All
Subject Author Date
Roger Taplin Sep 12, 2006 - 6:48 PM

I have some doubts about how well end-users cope with your date-time control.

(1) The control is not responsive to Delete and Backspace. I think a reasonable response would be to clear the current field (month, day, year, etc), and perhaps in the case of Backspace, to move back to the previous field.

(2) Selecting None from a drop-down calendar (date-picker) control prevents access to the control via a mouse click or tab. The control is unresponsive until a date is selected from the calendar control.

(3) What method should be used to assign a different font or font size to the control? The simple approach of creating a font and assigning it via CWnd::SetFont() does not work.

I have sub-classed your control to address the first of these problems, but I’m very much aware that a much more detailed analysis of the control’s inner workings than I can afford is required for my changes to be reliable.

For these reasons, the control not usable in my current application, yet in other respects it works very well.

I would appreciate your suggestions

Technical Support Sep 13, 2006 - 11:50 AM

1) The CExtDateTimeWnd control works in the same way as the CDateTimeCtrl does. The latter does not handle the Delete and Backspace keys. So we can only regard your idea as a feature request.

2) You can use the blank mode by invoking the SetBlank method: this sets the current date and all the CExtDateTimeWnd fields get blank. So the control is not empty and you can use the Tab key or mouse. To retrieve the date or time, you can use the GetDateTime method. Please note if either the day, month or year fields are empty, you will receive the COleDateTime object with the status set to COleDateTime::invalid, so you can check whether the date is entered and valid. The only question how to set the blank mode when the user selects the None button in the drop-down calendar. You can do this by handling the CExtDatePickerWnd::g_nMsgSelectionNotification notification. Please follow the steps below:

- Create the CExtDateTimeWnd derived class (i.e. CMyDateTimeWnd) and add a declaration of the handler method to the CMyDateTimeWnd header:

LRESULT OnDropDownCalendarSelChanged( WPARAM wParam, LPARAM lParam );
- Add the following macros to the message map:
ON_REGISTERED_MESSAGE(
            CExtDatePickerWnd::g_nMsgSelectionNotification,
            OnDropDownCalendarSelChanged
            )
- Add the implementation for this handler to <code>CMyDateTimeWnd:
LRESULT CMyDateTimeWnd::OnDropDownCalendarSelChanged( WPARAM wParam, LPARAM lParam )
{
 ASSERT_VALID( this );
 const CExtDatePickerWnd::SELECTION_NOTIFICATION * pSN =
  CExtDatePickerWnd::SELECTION_NOTIFICATION::FromWPARAM( wParam );
 ASSERT( pSN != NULL );
 if(  pSN->m_bFinalSelectionChanging 
  && (!IsReadOnly())
  )
 {
  if(  pSN->m_dtBegin.GetStatus() == COleDateTime::valid 
   && GetStatus() == CExtDateTimeWnd::valid
   )
   SetDateTime( 
    pSN->m_dtBegin.GetYear(),
    pSN->m_dtBegin.GetMonth(),
    pSN->m_dtBegin.GetDay(),
    m_dtDate.GetHour(),
    m_dtDate.GetMinute(),
    m_dtDate.GetSecond(),
    true, true
    );
  else
   SetBlank( true );
 }
 return 0L;
}
The selection handling is demonstrated in the ProfUIS_Controls sample

3) In the CExtDurationWnd class, you can find the OnQueryFont virtual method, which is used for retrieving the control’s font. You can override this method and return your own font handle.

Roger Taplin Sep 13, 2006 - 10:45 PM

(1) The day and month fields show no response until a second digit is received; the year field requires two digits. To my mind, this violates a fundamental requirement of a control, viz. that the control always responds to valid user activity.

(2) I have substituted an Initialize() function for SetBlank(), initializing the control date-time to Jan 1st, 2000. This overcomes the Day/Month/Year locale problem with the 31st day, but a problem with 29 Feb remains. In the latter case, users must enter the day, month, year, then return to the day to set the day to 29.

Roger Taplin Sep 13, 2006 - 6:59 PM

A fixed point font provides end-users with a useful cue that a four digit year is required, so that issue is easily dealt with.

The implicit use of the current date is a significant problem, however. For example, when the short date format for a locale is Day/Month/Year and the month is September, a user cannot directly enter a birth date such as 31/12/1956 into a completely empty control. The control uses the current month to deny the validity of 31, even though the month and year fields are blank.

My approach to implementing field blanking for Delete and Backspace has been to employ your field blanking flags: m_bBlankYear, etc. This appears to work well, except for the continuing presence of an implicit date. I suspect that the validation strategy underlying the control is a problem. It might be better if validation was to be delayed until all fields have values.

Roger Taplin Sep 13, 2006 - 5:54 PM

Thank you for your prompt and helpful reply.

With regard to implementing responses to Delete and Backspace key presses, Suhai Gyorgy is correct in pointing out the effect upon interpreting date-time values. However, my approach has been to cascade blanking of fields, depending upon locale. For example, when the date format is DD/MM/YYYY, pressing delete in the month field resets both the month and year fields, and pressing delete in the day field resets the entire control.

I also think that it would be helpful to end-users if the control provided cues that show that 4 digit year is required. My experiments with entering a 2 digit year into the control suggest to me that users would find the effect quite confusing.

I’m inclined to think that there is still some way to go in developing a control that end-users will find optimal, assuming that they frequently need to enter day, month, year values rather than select a date from the drop-down calendar.

Technical Support Sep 14, 2006 - 10:45 AM

The year format is retrieved from the local user locale settings. This is done in the CExtDurationWnd::OnQueryYearFormat() virtual method. You can override this method end specify how many you want to display, two or four.

Suhai Gyorgy Sep 13, 2006 - 3:39 AM

You can set the font by deriving your own class and overriding HFONT OnQueryFont() method, returning the desired font.

As for the rest, I can only guess that this control shouldn’t be considered as an edit control. Those restricitions are probably for making the verifying process much-much easier. I can’t imagine using the control as you suggested. For example if I delete the month field, it’d show text like 13/ /2006. And if I at this point leave the control, as what date would that text be interpreted? Same goes for selecting None and having the control empty of text. If control lets you type in it whatever you like, how could it interpret what you wrote? But well, this is only my opinion.