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 » OnInplaceControlDateTimeInputVerify not called when changing time from drop-list calender Collapse All
Subject Author Date
Offer Har Mar 18, 2010 - 4:49 AM

Hi,


When editing the time from the cell OnInplaceControlDateTimeInputVerify is called, when changing from the drop-list it’s not called. I see that OnValueChanging is called when changing from the drop list, however this function is also called when changing the value of cell from the code (SetDateTime) which makes it very complicated to handle user input in one place - can you please change it to be more user friendly, or at-least add a flag to OnValueChanging so we’ll know if the change came from the user or from the code?


Thanks,


Ron.

Technical Support Mar 22, 2010 - 11:40 AM

The CExtGridCellDateTime::OnValueChanging() / CExtGridCellDateTime::OnValueChanged() virtual methods really provide unified notifications. Do you want us to add similar methods into the CExtGridWnd class?

Offer Har Mar 22, 2010 - 12:54 PM

There are two problems:


1. I need it in the grid, not going to derive a cell for every validation


2. I need to know when the user changed the value, and not from elsewhere in the code.

Technical Support Mar 23, 2010 - 10:57 AM

There are only three ways to modify the date-time cell’s value:

1) Editing text in the in-place activated date-time editor window. The CExtGridCellDateTime::OnInplaceControlDateTimeInputComplete() and CExtGridWnd::OnGridCellInplaceControlDateTimeInputComplete() virtual methods allow you to intercept this event.

2) Pressing the date-time grid cell’s built-in up-down button arrows. The CExtGridCell::OnQueryEnabledIncrement(), CExtGridWnd::OnGridHookCellQueryEnabledIncrement(), CExtGridCellDateTime::OnValueIncrement() and CExtGridWnd::OnGridHookCellValueIncrement()</code> virtual methods allow you to intercept this event and even disable up and/or down parts of the built-in cell’s up-down button.

3) Picking the date item in the popup calendar control. The CExtGridCellDateTime::OnPopupDatePickerSelChange() virtual method allows you to intercept this event.

The third case does not have a similar virtual method in the grid control. We added it:

   virtual bool OnGridCellPopupDatePickerSelChange( LPVOID pSelectionNotification, CExtGridCell::TrackCellStateInfo_t & _tcsi );

bool CExtGridWnd::OnGridCellPopupDatePickerSelChange( LPVOID pSelectionNotification, CExtGridCell::TrackCellStateInfo_t & _tcsi )
{
            __EXT_DEBUG_GRID_ASSERT_VALID( this );
            ASSERT( pSelectionNotification != NULL );
            pSelectionNotification; _tcsi;
            return false;
}

Please also update the source code of the CExtGridCellDateTime::OnPopupDatePickerSelChange() and CExtGridCellDateTime::OnButtonPopupMenuTrack() virtual method:
 bool CExtGridCellDateTime::OnPopupDatePickerSelChange(
            LPVOID pSelectionNotification
            )
{
            __EXT_DEBUG_GRID_ASSERT_VALID( this );
const CExtDatePickerWnd::SELECTION_NOTIFICATION * pSN = CExtDatePickerWnd::SELECTION_NOTIFICATION::FromWPARAM( (WPARAM)pSelectionNotification );
            if( pSN == NULL )
                        return false;
            if( pSN->m_hWndDatePicker != NULL && ::IsWindow( pSN->m_hWndDatePicker ) )
            {
                        CExtDatePickerWnd * pWndDatePicker = DYNAMIC_DOWNCAST( CExtDatePickerWnd, CWnd::FromHandlePermanent( pSN->m_hWndDatePicker ) );
                        if( pWndDatePicker != NULL )
                        {
                                    CExtPopupDatePickerMenuWnd * pPopup = DYNAMIC_DOWNCAST( CExtPopupDatePickerMenuWnd, pWndDatePicker->GetParent() );
                                    if( pPopup->GetSafeHwnd() != NULL )
                                    {
                                                CExtGridCell::TrackCellStateInfo_t * p_tcsi = (CExtGridCell::TrackCellStateInfo_t *) pPopup->m_lParamCookie;
                                                if( p_tcsi != NULL && p_tcsi->m_wndGrid.GetSafeHwnd() != NULL )
                                                {
                                                            __EXT_DEBUG_GRID_ASSERT_VALID( (&p_tcsi->m_wndGrid) );
                                                            __EXT_DEBUG_GRID_ASSERT_KINDOF( CExtGridWnd, (&p_tcsi->m_wndGrid) );
                                                            if( p_tcsi->m_wndGrid.OnGridCellPopupDatePickerSelChange( pSelectionNotification, *p_tcsi ) )
                                                                        return true;
                                                }
                                    }
                        }
            }
            if( pSN->m_bFinalSelectionChanging )
            {
                        if(                     pSN->m_dtBegin.GetStatus() == COleDateTime::valid 
                                    &&        m_dtDate.GetStatus() == COleDateTime::valid
                                    )
                                    SetDateTime( 
                                                pSN->m_dtBegin.GetYear(), pSN->m_dtBegin.GetMonth(), pSN->m_dtBegin.GetDay(),
                                                m_dtDate.GetHour(), m_dtDate.GetMinute(), m_dtDate.GetSecond()
                                                );
                        else
                                    SetDateTime( pSN->m_dtBegin );
            }
            return true;
}

bool CExtGridCellDateTime::OnButtonPopupMenuTrack(
            CExtGridCell::TrackCellStateInfo_t & _tcsi
            )
{
            __EXT_DEBUG_GRID_ASSERT_VALID( this );
            __EXT_DEBUG_GRID_ASSERT( (&_tcsi.m_cell) == this );
            __EXT_DEBUG_GRID_ASSERT_VALID( (&_tcsi.m_wndGrid) );
            if( _tcsi.m_nButtonType != INT(__EBTT_DROPDOWN) )
                        return CExtGridCellEx::OnButtonPopupMenuTrack( _tcsi );
            // move focus and selection to the cell
DWORD dwSiwStyles = _tcsi.m_wndGrid.SiwGetStyle();
            if( ( dwSiwStyles & __EGBS_SFB_MASK ) != __EGBS_SFB_NONE && _tcsi.m_nColType == 0 && _tcsi.m_nRowType == 0  )
            {
                        CPoint ptFocusOld = _tcsi.m_wndGrid.FocusGet();
                        CPoint ptFocusDesired( _tcsi.m_nColNo, _tcsi.m_nRowNo );
                        CRect rcSelectionOld = _tcsi.m_wndGrid.SelectionGet( false, -1 );
                        CRect rcSelectionDesired( _tcsi.m_nColNo, _tcsi.m_nRowNo, _tcsi.m_nColNo, _tcsi.m_nRowNo );
                        if( (dwSiwStyles & __EGBS_SFB_MASK) == __EGBS_SFB_FULL_ROWS )
                        {
                                    LONG nColumnCount = _tcsi.m_wndGrid.ColumnCountGet();
                                   rcSelectionDesired.SetRect( 0, _tcsi.m_nRowNo, nColumnCount - 1, _tcsi.m_nRowNo );
                        }
                        if( (dwSiwStyles & __EGBS_SFB_MASK) == __EGBS_SFB_FULL_COLUMNS )
                        {
                                    LONG nRowCount = _tcsi.m_wndGrid.RowCountGet();
                                   rcSelectionDesired.SetRect( _tcsi.m_nColNo, 0, nRowCount - 1, _tcsi.m_nColNo );
                        }
                        if(                     ptFocusDesired != ptFocusOld 
                                    ||           rcSelectionOld != rcSelectionDesired
                                    )
                        {
                                    if( ptFocusDesired != ptFocusOld )
                                                _tcsi.m_wndGrid.FocusSet( ptFocusDesired, true, true, false, false );
                                    if( rcSelectionOld != rcSelectionDesired )
                                                _tcsi.m_wndGrid.SelectionSet( rcSelectionDesired, true, false, false );
                                    _tcsi.m_wndGrid.OnSwDoRedraw();
                        }
            }
            _tcsi.m_wndGrid.InvalidateRect( &_tcsi.m_rcCellExtra );
            _tcsi.m_wndGrid.OnSwUpdateWindow();
CExtPopupDatePickerMenuWnd * pPopup =
                        STATIC_DOWNCAST(
                                    CExtPopupDatePickerMenuWnd,
                                    CExtPopupMenuWnd::InstantiatePopupMenu( _tcsi.m_wndGrid.GetSafeHwnd(), RUNTIME_CLASS(CExtPopupDatePickerMenuWnd), this )
                                    );
            if( ! pPopup->CreatePopupMenu( _tcsi.m_wndGrid.GetSafeHwnd() ) )
            {
                        delete pPopup;
                        __EXT_DEBUG_GRID_ASSERT( FALSE );
                        return true;
            }
            pPopup->m_dwDatePickerStyle = OnQueryDatePickerStyle();
            pPopup->m_pCbDatePickerSelection = (CExtPopupInplaceDatePicker::pCbDatePickerSelection) stat_CbDatePickerSelection;
            pPopup->m_pDatePickerSelectionCookie = (LPVOID)this;
            pPopup->m_pCbInitDatePickerContent = (CExtPopupInplaceDatePicker::pCbInitDatePickerContent) stat_CbInitDatePickerContent;
            pPopup->m_pInitDatePickerCookie = (LPVOID)this;
            pPopup->m_lParamCookie = (LPARAM) (LPVOID) (&_tcsi);
CRect wr( _tcsi.m_rcCell );
            _tcsi.m_wndGrid.ClientToScreen( &wr );
CPoint ptTrack( wr.BottomRight() );
            ptTrack.x += pPopup->OnQueryMenuShadowSize();
CRect rcExclude( ptTrack, ptTrack );
HWND hWndGrid = _tcsi.m_wndGrid.m_hWnd;
            g_pCellMenuTracking = this;
            if( ! pPopup->TrackPopupMenu(
                                    TPMX_RIGHTALIGN | TPMX_COMBINE_NONE | TPMX_DO_MESSAGE_LOOP,
                                    ptTrack.x, ptTrack.y, &rcExclude, this, NULL, NULL, true
                                    )
                        )
            {
                        g_pCellMenuTracking = NULL;
                        //delete pPopup;
                        __EXT_DEBUG_GRID_ASSERT( FALSE );
                        return true;
            }
            if( ! ::IsWindow( hWndGrid ) )
                        return true;
            if( g_pCellMenuTracking == this )
                        g_pCellMenuTracking = NULL;
            else if( g_pCellMenuTracking == NULL )
                        return true;
            _tcsi.m_wndGrid.InvalidateRect( &_tcsi.m_rcCellExtra );
            _tcsi.m_wndGrid.OnGridCellInputComplete( *this, _tcsi.m_nColNo, _tcsi.m_nRowNo, _tcsi.m_nColType, _tcsi.m_nRowType );
            return OnButtonPopupMenuComplete( _tcsi );
}
The LPVOID pSelectionNotification parameter is the pointer to the CExtDatePickerWnd::SELECTION_NOTIFICATION data structure in both methods. This data structure has the m_bFinalSelectionChanging property which is false when the user just moves mouse over date item. It’s true when the user picked some date item.

Technical Support Mar 20, 2010 - 11:26 AM

The CExtGridCell::OnInplaceControlDateTimeInputVerify() virtual method and the corresponding CExtGridWnd::OnGridCellInplaceControlDateTimeInputVerify virtual method have the InplaceControl text in the method names because these methods are related to the in-palace activated date time editor control looking like validating/masked text editor controls. If you need to handle the date-time cell’s up-down and drop-down buttons, then you should override the CExtGridCellDateTime::OnValueChanging() / CExtGridCellDateTime::OnValueChanged() virtual methods.

Offer Har Mar 20, 2010 - 1:56 PM

Hi,


There is a problem with this design:


1) Usually, we need to validate user’s inputs - and according to your answer there is no one place to validate it.


2) When validating user’s inputs, I do not want to check code inputs, it is also calling OnValueChanging.


Do you plan of fixing this for the coming versions?