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 » Grid Cell tooltips Collapse All
Subject Author Date
Andrew Banks May 13, 2007 - 1:52 PM

Can’t find doc or samples that describe how to use grid cell tooltips.

Can you please help.

Thanks

Technical Support May 14, 2007 - 8:39 AM

You can set custom tooltip text for a cell by overridding the CExtGridCell::OnInitToolTip() method in the cell class like as follows:

// DECLARATION
class CExtGridCellTooltip : public CExtGridCell
{
public:
      DECLARE_SERIAL( CExtGridCellTooltip );
      IMPLEMENT_ExtGridCell_Clone( CExtGridCellTooltip, CExtGridCell );
      CExtGridCellTooltip(
            CExtGridDataProvider * pDataProvider = NULL
            );
      // virtual methods
      virtual bool OnInitToolTip(
            CExtGridWnd & wndGrid,
            const CExtGridHitTestInfo & htInfo,
            CToolTipCtrl & wndToolTip,
            UINT nToolNo,
            const RECT & rcTool
            );
}; // class CExtGridCellTooltip

//IMPLEMENTATION
/////////////////////////////////////////////////////////////////////////////
// CExtGridCellTooltip
IMPLEMENT_SERIAL( CExtGridCellTooltip, CExtGridCell, VERSIONABLE_SCHEMA|1 );
CExtGridCellTooltip::CExtGridCellTooltip(
      CExtGridDataProvider * pDataProvider // = NULL
      )
      : CExtGridCell ( pDataProvider )
{
}
bool CExtGridCellTooltip::OnInitToolTip(
    CExtGridWnd & wndGrid,
    const CExtGridHitTestInfo & htInfo,
    CToolTipCtrl & wndToolTip,
    UINT nToolNo,
    const RECT & rcTool
    )
{
    ASSERT_VALID( this );
    ASSERT_VALID( (&wndGrid) );
    ASSERT( ! htInfo.IsHoverEmpty() );
    ASSERT( htInfo.IsValidRect() );
    htInfo;
bool bRetVal = false;
CExtSafeString strText( _T("Tooltip Text") );
    if( strText.GetLength() > 0 )
    {
        wndToolTip.AddTool(
            &wndGrid,
            (LPCTSTR)strText,
            &rcTool,
            nToolNo
            );
        bRetVal = true;
    }
    if( ! bRetVal )
    {
        wndToolTip.DelTool( &wndGrid, nToolNo );
        CWnd::CancelToolTips();
    } // if( ! bRetVal )
    return bRetVal;
}
Here is how you can use it
CExtGridCellTooltip * pCellTooltip =
    STATIC_DOWNCAST(
        CExtGridCellTooltip,
        m_wndGrid.GridCellGet(
            4,
            nRowNo,
            0,
            0,
            RUNTIME_CLASS(CExtGridCellTooltip)
        )
);
Please note you should disable the content pop-up window for grid cells. Such a tooltip-like window shows the cell content for a cell which is partially visible.
m_wndGrid.EnableTooltips(
            true,
            true,
            true,
            true,
            true
            );
m_wndGrid.EnableExpanding(
            false,
            false,
            false,
            false,
            false
            );