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 General Discussion » CExtGridWnd and tool tips Collapse All
Subject Author Date
David Sousa Oct 12, 2006 - 7:24 AM

Is it possible to selectively choose which cells of a grid will display tool tips? I have a 4 column grid. 3 of the columns are CExtGridCellString cells which don’t need tool tips. The 4th cell is a custom cell that is similar to CExtGridCellProgress. It basically just draws a fixed, solid rectangle in a portion of the cell that is used for a time line display.

I would like to only display a tool tip when the user moves the mouse over the portion of the 4th cell that is displaying the time line bar.

I can get tool tips to display on all of the cells by using __EGBS_EX_CELL_TOOLTIPS_INNER.

Thanks.

Technical Support Oct 13, 2006 - 8:23 AM

To set custom tooltip text for the cell, you can also override the CExtGridCell::OnInitToolTip virtual method in the cell class.

Your CExtGridCell (or any other) derived class may look like:


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

To use this class use the following code:

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



Suhai Gyorgy Oct 13, 2006 - 3:44 AM

Use the __EGBS_EX_CELL_TOOLTIPS_INNER style and try overriding method bool CExtGridWnd::OnGbwTooltip( const CExtGridHitTestInfo & htInfo). From htInfo parameter you can find out over which cell the mouse is and if at that point you don’t want any tool tip, just return false, otherwise call base class’ method. I didn’t try it though.