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
|