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 » CExtGridCellButton and tooltips Collapse All
Subject Author Date
Byron Blattel Aug 29, 2007 - 2:38 PM

I’ve overidden CExtGridCellButton::OnGetToolTipText() but it’s not getting called.

I’ve also tried overiding MyReportGrid::OnGridCellGetToolTipText(), it get’s called for header cells but not for inner cells. I have the __EGBS_EX_CELL_TOOLTIPS style set and cells that are narrower than their text display the tooltip, even though OnGridCellGetToolTipText() is not called. I’m also calling EnableTooltips()...

What am I missing?

Technical Support Aug 30, 2007 - 11:38 AM

You can set custom tooltip text for a cell by overriding 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
            );


Byron Blattel Aug 30, 2007 - 5:29 PM

It was the expanding tips part that was the problem.

I need to have a separate tooltip for the button cells and keep the so-called ’expanding’ tips. I have buttons in cells that are just icons, no text.

I’ve gotten it to work by overriding OnGbwHoverRecalc() to allow both ’bExpandItem’ and ’bTooltipItem’ to be true by eliminating the ’else if’s and added a premature call to OnGbwTooltip() before checking ’bExpandItem’ and ’bTooltipItem’. This works as expected if I return true from my OnGridCellGetToolTipText() override and leave strToolTipText empty (so that the buried call to CExtGridCell::OnInitAdvancedTip() returns false).

I’d like to make a feature request that both expanding tips and ’overriden’ tips be possible in the core product.

Technical Support Sep 3, 2007 - 10:15 AM

This feature is already in our TO-DO list. We will notify you when it is ready.