![]() |
Tooltip in Treecontrol |
Post Reply
|
| Author | |
Alex H.
Senior Member
Joined: 12 February 2004 Status: Offline Points: 266 |
Post Options
Thanks(0)
Quote Reply
Topic: Tooltip in TreecontrolPosted: 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! |
|
![]() |
|
znakeeye
Senior Member
Joined: 26 July 2006 Status: Offline Points: 1672 |
Post Options
Thanks(0)
Quote Reply
Posted: 26 October 2010 at 11:29am |
|
PokerMemento - http://www.pokermemento.com/
|
|
![]() |
|
Alex H.
Senior Member
Joined: 12 February 2004 Status: Offline Points: 266 |
Post Options
Thanks(0)
Quote Reply
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); } |
|
![]() |
|
Alex H.
Senior Member
Joined: 12 February 2004 Status: Offline Points: 266 |
Post Options
Thanks(0)
Quote Reply
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! |
|
![]() |
|
Post Reply
|
|
|
Tweet
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |