Print Page | Close Window

How to: Codejock tooltips on a tree control

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=8578
Printed Date: 08 May 2025 at 5:32am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: How to: Codejock tooltips on a tree control
Posted By: rdhd
Subject: How to: Codejock tooltips on a tree control
Date Posted: 29 October 2007 at 1:54pm

The codejock tooltip control is not based on the MFC tooltip control. The MFC tree control has a method to set the tooltip control but it takes in a CToolTipCtrl (or derived) class.

How can I get the tree control to work with codejock tooltips?
 
I found a codejock tree control and it is derived from the MFC control. But it does not implement (as far as I can tell) any method to set a codejock tooltip.
 
 



Replies:
Posted By: mgampi
Date Posted: 30 October 2007 at 4:47am
Hi;
 
I did it this way:
Turn off the internal tooltip control (TVS_NOTOOLTIPS) and replace it by a CXTPTooltipContext. This is a member of my tree control and handles all tooltip messages in OnWndMsg() (see code below).
I hope this helps. BTW if you prefer to use other tooltip paintings, you have to modify the tooltip context by deriving your own class...
 
class CMyTree : public CXTTreeCtrl
{
public:
 CMyTree();
 virtual ~CMyTree();
protected:
 virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
private:
 BOOL    OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult);
 INT_PTR   OnToolHitTest(CPoint point, TOOLINFO* pTI) const;
 CXTPToolTipContext* pContext_;
};
////////////////////////////////////////////////////
BOOL CMyTree::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult) {
 if (pContext_!=0)
  pContext_->FilterToolTipMessage(this, message, wParam, lParam);
 
 return CXTTreeCtrl::OnWndMsg(message, wParam, lParam, pResult);
}

INT_PTR CMyTree::OnToolHitTest(CPoint point, TOOLINFO* pTI) const {
 // hits against child windows always center the tip
 INT_PTR nHit = CWnd::OnToolHitTest(point, pTI);
 if (nHit!=-1)
  return nHit;
 if (pTI != NULL && pTI->cbSize >= sizeof(XTP_TOOLTIP_TOOLINFO))
 {
  UINT nFlags;
  HTREEITEM hItem=HitTest(point, &nFlags);
  if ((hItem != NULL) && (TVHT_ONITEM & nFlags)) {
   CRect rc;
   VERIFY(GetItemRect(hItem, rc, FALSE));
   nHit=reinterpret_cast<INT_PTR>(hItem);
   const MyObject* const pVar=dynamic_cast<MyObject*>(reinterpret_cast<MyBaseObject*>(GetItemData(hItem)));
   ASSERT(pVar!=NULL);
   if (pVar!=NULL) {
    TCHAR szText[4096];
    pVar->GetTooltipInfoText(szText, _countof(szText));
    CXTPToolTipContext::FillInToolInfo(pTI, m_hWnd, rc, nHit, szText);
    return nHit;
   }
  }
 }
 pContext_->CancelToolTips();
 return -1;
}


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net