Tooltip in Treecontrol
Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=17489
Printed Date: 20 June 2025 at 5:44am Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: Tooltip in Treecontrol
Posted By: Alex H.
Subject: Tooltip in Treecontrol
Date Posted: 26 October 2010 at 10:15am
How can i add an individual tooltip to each tree control? It would be nice if this tooltip could be of type xtpToolTipMarkup!
Please help!
|
Replies:
Posted By: znakeeye
Date Posted: 26 October 2010 at 11:29am
http://forum.codejock.com/forum_posts.asp?TID=9133 - http://forum.codejock.com/forum_posts.asp?TID=9133
------------- PokerMemento - http://www.pokermemento.com/
|
Posted By: Alex H.
Date Posted: 27 October 2010 at 3:37am
Thank you for your help but it doesn't work -> any idea? I use toolkit version 13.4. My class is derived form CUIXTreeCtrl which is based on CXTTreeCtrl.
here is my code:
//----------------------------------------------------------------------------- int CUIActiveUsersTreeCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct) //----------------------------------------------------------------------------- { if (CUIXTreeCtrl::OnCreate(lpCreateStruct) == -1) return -1;
// Create the image list used by the tree control. if ( !m_imageList.Create( 16, 16, ILC_COLOR24 | ILC_MASK, 1, 1 ) ) { TRACE0("Failed to create image list.\n"); return -1; }
// load the tree images bitmap and add it to the image list. m_bitmap.LoadBitmap( IDB_IMGLIST_VIEW ); m_imageList.Add(&m_bitmap, RGB(255,0,255));
// Set the image list for the tree control. SetImageList( &m_imageList, TVSIL_NORMAL );
m_TTContext.SetStyle(xtpToolTipMarkup); m_TTContext.ShowTitleAndDescription(TRUE); SetToolTips(NULL); return 0; }
BOOL CUIActiveUsersTreeCtrl::PreCreateWindow(CREATESTRUCT& cs) { if ( !CUIXTreeCtrl::PreCreateWindow( cs ) ) return FALSE;
// Set the style for the tree control. cs.style |= TVS_DISABLEDRAGDROP; cs.style &= ~TVS_HASLINES; cs.style &= ~TVS_LINESATROOT; cs.style &= ~TVS_HASBUTTONS;
// If non-xp mode, add a client edge border to the tree. if (!xtAfxData.bXPMode) { cs.dwExStyle |= WS_EX_CLIENTEDGE; }
cs.style |= TVS_NOTOOLTIPS;
return TRUE; }
CString CreateMarkupTool(LPCTSTR strCaption, LPCTSTR strDesc) { CString strHTML; strHTML.Format( _T("<StackPanel Margin='1' MaxWidth='200'>") _T("<TextBlock Padding='1, 3, 1, 3' FontWeight='Bold'>%s</TextBlock>") _T("<TextBlock Padding='9, 6, 30, 7' TextWrapping='Wrap'>%s</TextBlock>") _T("<Border Height='1' Background='#9ebbdd' />") _T("<Border Height='1' Background='White' />") _T("</StackPanel>"), strCaption, strDesc); return strHTML; }
INT_PTR CUIActiveUsersTreeCtrl::OnToolHitTest(CPoint point, TOOLINFO* pTI) const { // check child windows first by calling CControlBar INT_PTR nHit = CWnd::OnToolHitTest(point, pTI); if (nHit != -1) return nHit;
HTREEITEM hTreeItem = GetItemFromPoint(point); // this is yust a helper to get item under cursor if(hTreeItem) { nHit = (INT_PTR) hTreeItem; m_TTContext.FillInToolInfo(pTI, GetSafeHwnd(), CRect(point, CSize(100, 100) ), nHit, CreateMarkupTool(_T("XXX Test"), _T("YYY TEST2")));
return nHit; } return -1; }
void CUIActiveUsersTreeCtrl::RelayEvent(UINT message, WPARAM wParam, LPARAM lParam) { MSG msg; msg.hwnd= m_hWnd; msg.message= message; msg.wParam= wParam; msg.lParam= lParam; POINT pt; pt.x = LOWORD (lParam); pt.y = HIWORD (lParam);
ClientToScreen(&pt);
msg.time= clock();
msg.pt.x= pt.x;
msg.pt.y= pt.y;
m_TTContext.FilterToolTipMessage(this, &msg); }
BOOL CUIActiveUsersTreeCtrl::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult) { //m_TTContext.FilterToolTipMessage(this, message, wParam, lParam); if (message == WM_MOUSEMOVE) RelayEvent(message, wParam, lParam);
return CUIXTreeCtrl::OnWndMsg(message, wParam, lParam, pResult); }
|
Posted By: Alex H.
Date Posted: 27 October 2010 at 4:20am
Ok it works now :-)
Changed the code in on ToolHitTest
... HTREEITEM hTreeItem = HitTest(point, &nFlags); // GetItemFromPoint(point); if(pTI && hTreeItem) { nHit = reinterpret_cast<INT_PTR>(hTreeItem);
...
Once again - thank you for your help!
|
|