Windows Vista introduced a buch of extended styles for tree-view control (SysTreeView32). Among them, there is TVS_EX_RICHTOOLTIP style which is described in MSDN documentation as follows: “Allow rich tooltips in the tree view (custom drawn with icon and text)”. This article shows a little bit more about how to set and which is the effect of using this extended style.
How to set and remove TVS_EX_RICHTOOLTIP style
Like the other tree-view extended styles, TVS_EX_RICHTOOLTIP can be set or removed as follows:
Sending TVM_SETEXTENDEDSTYLE message
1 2 3 4 5 6 7 |
DWORD dwExMask = TVS_EX_RICHTOOLTIP; // if m_bRichTooltip is true TVS_EX_RICHTOOLTIP is set // otherwise it is removed DWORD dwExStyles = m_bRichTooltip ? TVS_EX_RICHTOOLTIP : 0; HWND hWndTreeCtrl = ::GetDlgItem(hWndDlg, IDC_TREE_DEMO); ::SendMessage(hWndTreeCtrl, TVM_SETEXTENDEDSTYLE, (WPARAM)dwExMask, (LPARAM)dwExStyles); |
Using TreeView_SetExtendedStyle macro
1 2 3 4 5 6 7 |
UINT uExMask = TVS_EX_RICHTOOLTIP; // if m_bRichTooltip is true TVS_EX_RICHTOOLTIP is set // otherwise it is removed DWORD dwExStyles = m_bRichTooltip ? TVS_EX_RICHTOOLTIP : 0; HWND hWndTreeCtrl = ::GetDlgItem(hWndDlg, IDC_TREE_DEMO); TreeView_SetExtendedStyle(hWndTreeCtrl, dwExStyles, uExMask); |
Calling CTreeCtrl::SetExtendedStyle (MFC)
1 2 3 4 5 6 7 8 9 10 11 |
void CWhateverDialog::_SetOrRemoveRichTooltipStyle() { UpdateData(); DWORD dwExMask = TVS_EX_RICHTOOLTIP; // if m_bRichTooltip is true TVS_EX_RICHTOOLTIP is set // otherwise it is removed DWORD dwExStyles = m_bRichTooltip ? TVS_EX_RICHTOOLTIP : 0; m_treeCtrl.SetExtendedStyle(dwExMask, dwExStyles); } |
Further, let’s use the above code and see what’s happen.
The effect of TVS_EX_RICHTOOLTIP style
By default, if the mouse pointer hovers a partially visible tree item, a tootip containing the item’s text is shown.
If the TVS_EX_RICHTOOLTIP style is set, then the tooltip displays the item’s icon in addition to the item’s text.
Note that TVS_EX_RICHTOOLTIP has no effect if TVS_INFOTIP style is set. In this case, the tooltip shows the text provided in TVN_GETINFOTIP notification handler and no icon. So far, that’s all I found about it. If somebody can reveal more, please do not hesitate to leave a reply!
Downloads
Demo project (Visual Studio 2013) – TVS_EX_RICHTOOLTIP_Demo.zip (1351)