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 » Locating row/column mouse clicks in CExtReportGridWnd derived controls Collapse All
Subject Author Date
Christophe Guibert Sep 10, 2006 - 7:47 AM

Hello,

I’m sure this is an easy question for you : what’s the best method to be notified of mouse clicks in CExtReportGridWnd derived controls, AND know the corresponding row and column in the grid ?

Using OnGbwAnalyzeCellMouseClickEvent() virtual method gives a CPoint information : how can we deduce the corresponding row and column in the grid ?

Another idea : the ReportItemFocusGet() gives the CExtReportGridItem where the click was done. Is there and equivalent to retrieve the CExtReportGridColumn ?

Thanks in advance,

Christophe Guibert

Technical Support Sep 11, 2006 - 6:51 AM

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 );

Christophe Guibert Sep 12, 2006 - 3:49 PM

Thank you very much : this was exactly what I was looking for.
Best Regards,
C. Guibert