Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - ToolTipContxt for items in CTreeCtrl
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ToolTipContxt for items in CTreeCtrl

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

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Topic: ToolTipContxt for items in CTreeCtrl
    Posted: 18 December 2007 at 7:21am
I'm trying to display Office2007-styled tooltips for all items in my CXTTreeCtrl-derived class. This seems tricky! I found this piece of information, but I still can't get it to work: http://forum.codejock.com/forum_posts.asp?TID=8578&KW=tree+tooltip
 
Any ideas on how to accomplish this?
Back to Top
rdhd View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 August 2007
Location: United States
Status: Offline
Points: 867
Post Options Post Options   Thanks (0) Thanks(0)   Quote rdhd Quote  Post ReplyReply Direct Link To This Post Posted: 19 December 2007 at 2:29pm
Unfortunately CJ does not provide a tooltip control that is subclassed from the MFC tooltip control. Otherwise one could just call SetToolTips and pass in the pointer to a subclassed control. So its a bit harder to do but can be done.
 
First call CTreeCtrl's SetToolTips(NULL) - that turns off the MFC tooltips in the CTreeCtrl (which if I remember correct codejock does subclass CXTTreeCtrl from).
 
Then you have to relay mouse messages to the context using the CJ context's FilterToolTipMessage method (if you relay the mouse event from a handler you have to convert from client to screen). That goes something like this (I subclassed CTreeCtrl to get the mouse messages and implemented a "RelayEvent" method where I pass in e.g., WM_MOUSEMOVE as the first arg):

void MyListCtrl::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_ToolTipContext.FilterToolTipMessage(this, &msg);

}

Then you also need to implement OnToolHitTest and OnToolTipText (depending on how you want to supply the text - it can be supplied in the OnToolHitTest routine).

Make sure the ID you provide in OnToolHitTest changes with each cell or CJ won't ask for the text. I do something like this in OnToolHitTest:

pTI->rect = rectCell;

pTI->hwnd = m_hWnd;

pTI->uId = (UINT)(( nItem << 10 ) + (hi.iSubItem & 0x3ff) + 1 );

pTI->lpszText = LPSTR_TEXTCALLBACK;

Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 02 January 2008 at 4:06am
Thanks for your response. Though, I can't get it working here. OnToolHitTest and OnToolTipText are never called
 
Here is my WM_MOUSEMOVE trap:
 
BOOL CMyTreeCtrl::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT *pResult)
{
 if (message == WM_MOUSEMOVE)
  RelayEvent(message, wParam, lParam);
...
}
 
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post Posted: 03 January 2008 at 4:58am
For God's sake! Solved it...
 
I had removed "const" from the OnToolHitTest declaration, due to a call to the non-const function CancelToolTips()...
 
I had a feeling long ago, but I ignored it until now. Thanks for your code. I believe I can use it here.
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.172 seconds.