The OnGbwAnalyzeCellMouseClickEvent()
virtual method receives the CPoint point
parameter which is the mouse click location in grid’s client coordinates. So, first of all we should convert it into zero based row/column numbers inside the grid window using hit-testing:
CExtReportGridWnd * pReportGridWnd = . . .
CExtGridHitTestInfo htInfo( point );
pReportGridWnd->HitTest( htInfo, false, true );
if( htInfo.IsHoverEmpty()
|| ( ! htInfo.IsValidRect() )
)
return . . .;
INT nColType = htInfo.GetInnerOuterTypeOfColumn();
INT nRowType = htInfo.GetInnerOuterTypeOfRow();
if( nColType != 0 || nRowType != 0 || htInfo.m_nColNo < 0 || htInfo.m_nRowNo < 0 )
return . . .;
Now the
htInfo.m_nColNo
and
htInfo.m_nRowNo
values specify valid row/column numbers in terms of
CExtGridWnd
class. We should convert them into the
CExtReportGridColumn *
and
CExtReportGridItem *
pointers which are used by the
CExtReportGridWnd
class:
CExtReportGridColumn * pRGC =
STATIC_DOWNCAST(
CExtReportGridColumn,
pReportGridWnd->GridCellGetOuterAtTop( htInfo.m_nColNo, 0L )
);
HTREEITEM hTreeItem = pReportGridWnd->ItemGetByVisibleRowIndex( htInfo.m_nRowNo );
CExtReportGridItem * pRGI = pReportGridWnd->ReportItemFromTreeItem( hTreeItem );
ASSERT_VALID( pRGI );
bool bReportItemIsGroupRow = ( pReportGridWnd->ItemGetChildCount( hTreeItem ) > 0 ) ? true : false;
if( bReportItemIsGroupRow )
return . . .; // WE THINK THIS IS NOT INTERESTING CASE
CExtGridCell * pCell = pReportGridWnd->ReportItemGetCell( pRGC, pRGI );