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.
Subject |
Author |
Date |
|
Luis Alberto Pereira
|
Jul 12, 2007 - 1:29 PM
|
I,
How can I change the standart text Tooltip of a CExtGridCell when it is hovered by mouse ?
thanks,
Luis
|
|
Technical Support
|
Jul 13, 2007 - 12:08 PM
|
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
);
|
|
Luis Alberto Pereira
|
Jul 14, 2007 - 7:52 PM
|
I done it, but I have problem because my cell is a Header Cell. I tried change standards mode to your sample and I get a error. How can I do it in a cell header ?
Thanks,
//cabecalho 1 for( LONG x = 0; x < nColCount; x ++ ) { CPlanoMetas_Cell_Header * pCell = STATIC_DOWNCAST(CPlanoMetas_Cell_Header, this->m_wndView.GridCellGetOuterAtTop(x, 0L,0,0,RUNTIME_CLASS (CPlanoMetas_Cell_Header)));
//CPlanoMetas_Cell_Header * pCell = (CPlanoMetas_Cell_Header*) // this->m_wndView.GridCellGetOuterAtTop( x, 0L, RUNTIME_CLASS( CPlanoMetas_Cell_Header));
pCell->TextSet(g_arrHdrNames[x]); pCell->ExtentSet(g_arrHdrExtents[x]); }
|
|
Technical Support
|
Jul 16, 2007 - 1:43 PM
|
You can display tooltips over header cells by applying the __EGBS_EX_CELL_TOOLTIPS_OUTER cell style by using the SiwModifyStyleEx() method.
|
|