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 General Discussion » Detect Today Button clicking in CExtDateTimeWnd Collapse All
Subject Author Date
Upanshu Yadav Sep 23, 2010 - 12:50 AM

How to detect the clicking of today button in CExtDateTimeWnd   calendar?

Upanshu Yadav Apr 26, 2011 - 1:17 AM

If there are two CExtDateTimeWnd controls present then how to find out from which control this click event is sent?

Technical Support Apr 26, 2011 - 9:42 AM

Please initialize the CExtDurationWnd::m_lParamCookie property of each date-time/duration control with unique identifier. Here is example:

    m_wndDuration.m_lParamCookie = LPARAM(IDC_DURATION);
    m_wndDateTime.m_lParamCookie = LPARAM(IDC_DATETIME);

Then you can use it in the registered message handlers:
. . .

    ON_REGISTERED_MESSAGE(
        CExtDateTimeWnd::g_nMsgChangingNotification,
        OnSelChangedDateTime
    )

. . .

LRESULT CPageDateTimeDuration::OnSelChangedDateTime( WPARAM wParam, LPARAM lParam )
{
    ASSERT_VALID( this );
    lParam;
    const CExtDateTimeWnd::CHANGING_NOTIFICATION * pCN =
        CExtDateTimeWnd::CHANGING_NOTIFICATION::FromWPARAM( wParam );
    ASSERT( pCN != NULL );
    if( pCN->m_lParamCookie == LPARAM(IDC_DATETIME) )
    {
. . .

The code snippets above are from the ProfUIS_Controls sample project.

Upanshu Yadav Apr 27, 2011 - 6:19 AM

How can i get the date  on which i clicked in the calendar control in OnSelChangedDateTime function ?Actually i want to change the time only and want to keep the date same equal to  the one i selected by clicking in the calendar?

Ahmad Khalid Oct 1, 2010 - 4:48 AM

But how can we differentiate a "Today" button click from a "None" button click or a click after selecting some specific date inside this method?

Technical Support Apr 27, 2011 - 1:34 PM

The CExtDateTimeWnd::CHANGING_NOTIFICATION describes both old and new date/times. You can compare them and set the correct date/time.

Technical Support Oct 1, 2010 - 12:17 PM

Here is how to detect it:

bool bNoneButtonClicked = ( pSN->m_dtBegin.GetStatus() == COleDateTime::null ) ? true : false;

Technical Support Sep 24, 2010 - 10:14 AM

You should handle the CExtDatePickerWnd::g_nMsgSelectionNotification registered message in your CExtDateTimeWnd-derived class exactly like the CExtDateTimeWnd does. Here is the message map entry:

   ON_REGISTERED_MESSAGE(
                        CExtDatePickerWnd::g_nMsgSelectionNotification,
                        OnDropDownCalendarSelChanged
                        )

Here is the method:
LRESULT CExtDateTimeWnd::OnDropDownCalendarSelChanged( WPARAM wParam, LPARAM lParam )
{
            ASSERT_VALID( this );
            lParam;
            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
                        {
                                    SetDateTime( 
                                                pSN->m_dtBegin,
                                                true, true
                                                );
                                    OnSelectItem( NULL );
                        }
            }
            return 0L;
}
The today button sends the same notification as the today’s date item in the calendar.