Objective Grid : PART II Programmer’s Guide : Chapter 27 GridEx Feature Pack Extension : Tool Tips
Tool Tips
Objective GridEx extends the tool tip functionality by deriving a new class CGXToolTipCtrlProxyEx from the CMFCToolTipCtrl class, extending the tool tip functionality to display an icon, a label, and a description. You can also customize a tool tip’s visual appearance using a gradient fill, custom text and border colors, bold text, rounded corners, or a balloon style.
Implementation
New class CGXToolTipCtrl derives from CMFCToolTipCtrl (files gxttnex.h, gxttnex.cpp).
New class CGXToolTipCtrlProxyEx derives from CGXNoToolTipCtrlProxy and uses CGXToolTipCtrl instead of CToolTipCtrl. The derived class overrides some functions including m_wndTtnToolTip (files gxttnex.h, gxttnex.cpp).
New template class CGXGridToolTipsEx<T> derives from CGXGridCore and overrides the following functions in GXGridToolTipsEx.h:
 
void ImplementToolTips();
BOOL EnableGridToolTips(BOOL b);
void SetToolTipParams(CMFCToolTipInfo* pParams);
A public accessor GetTooltipProxy() was added to return the protected member m_pTooltipProxy value in the CGXGridCore class (existing file gxcore.h).
The following instantiations are provided for convenience:
 
typedef CGXGridToolTipsEx<CGXGridView> CGXGridViewToolTipsEx;
typedef CGXGridToolTipsEx<CGXGridWnd> CGXGridWndToolTipsEx;
Setting Tool Tips in a Grid
On Grid initialization, call function EnableGridToolTips(TRUE).
The extended tool tips are now displayed with the current Windows theme or style, depending on the application style programmatically set. Using the CMFCToolTipInfo class to store information about the visual appearance of tool tips, you can customize a tool tip’s appearance or style by setting values on its various properties. For example:
 
CMFCToolTipInfo Params;
Params.m_bBoldLabel = FALSE;
Params.m_clrFill = RGB (255, 255, 255);
Params.m_clrFillGradient = RGB (228, 100, 24);
Params.m_clrText = RGB (0, 83, 255);
Params.m_clrBorder = RGB (255, 255, 0);
Params.m_bVislManagerTheme = TRUE;
Params.m_bDrawSeparator = FALSE;
Params.m_bRoundedCorners = TRUE;
Params.m_nGradientAngle = 30;
m_wndGrid.SetToolTipParams(&Params);
Please refer to the MSDN description at http://msdn.microsoft.com/en-us/library/bb984634.aspx for detailed information regarding the implementation and use of the CMFCToolTipInfo class.
Tool tips allow multiline text, formatted as "line1\nline2\nline3". The description is separated from the title with delimiter "@@". Then, add your multiline text to the following Grid function call, like so:
 
.SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT, "Color \nButton @@ CMFC ToolTip")
To display bitmaps in a tool tip, the bitmap file should be included in your application's resources using a resource ID, for example, IDB_BITMAP1. Then, add the bitmap resource to the following Grid function call:
 
.SetUserAttribute(GX_IDS_UA_TOOLTIPTEXT + 1, (LONG)IDB_BITMAP1)
Refer to “Registration and Usage of User Attributes” for more details.
Related Samples
Tool Tips are demonstrated in the following samples:
ToolTipColorPicker
VisualDataSet
ExcelGrid