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.