![]() |
How to: Codejock tooltips on a tree control |
Post Reply ![]() |
Author | |
rdhd ![]() Senior Member ![]() ![]() Joined: 13 August 2007 Location: United States Status: Offline Points: 921 |
![]() ![]() ![]() ![]() ![]() 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.
|
|
![]() |
|
mgampi ![]() Senior Member ![]() ![]() Joined: 14 July 2003 Status: Offline Points: 1201 |
![]() ![]() ![]() ![]() ![]() |
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 |
|
![]() |
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 |