Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - How to: Codejock tooltips on a tree control
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

How to: Codejock tooltips on a tree control

 Post Reply Post Reply
Author
Message
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 921
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Topic: How to: Codejock tooltips on a tree control
    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.
 
 
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.031 seconds.