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

Tooltip in Treecontrol

 Post Reply Post Reply
Author
Message
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Topic: Tooltip in Treecontrol
    Posted: 26 October 2010 at 10:15am
How can i add an individual tooltip to each tree control?
It would be nice if this tooltip could be of type xtpToolTipMarkup!

Please help!
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: 26 October 2010 at 11:29am
PokerMemento - http://www.pokermemento.com/
Back to Top
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Posted: 27 October 2010 at 3:37am
Thank you for your help but it doesn't work -> any idea?
I use toolkit version 13.4. My class is derived form CUIXTreeCtrl which is based on CXTTreeCtrl.

here is my code:

//-----------------------------------------------------------------------------
int CUIActiveUsersTreeCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
//-----------------------------------------------------------------------------
{
    if (CUIXTreeCtrl::OnCreate(lpCreateStruct) == -1)
        return -1;

    // Create the image list used by the tree control.
    if ( !m_imageList.Create( 16, 16, ILC_COLOR24 | ILC_MASK, 1, 1 ) )
    {
        TRACE0("Failed to create image list.\n");
        return -1;
    }

    // load the tree images bitmap and add it to the image list.
    m_bitmap.LoadBitmap( IDB_IMGLIST_VIEW );
    m_imageList.Add(&m_bitmap, RGB(255,0,255));  

    // Set the image list for the tree control.
    SetImageList( &m_imageList, TVSIL_NORMAL );

    m_TTContext.SetStyle(xtpToolTipMarkup);
    m_TTContext.ShowTitleAndDescription(TRUE);
    SetToolTips(NULL);

       
    return 0;
}

BOOL CUIActiveUsersTreeCtrl::PreCreateWindow(CREATESTRUCT& cs)
{
    if ( !CUIXTreeCtrl::PreCreateWindow( cs ) )
        return FALSE;

    // Set the style for the tree control.   
    cs.style |= TVS_DISABLEDRAGDROP;   
    cs.style &= ~TVS_HASLINES;
    cs.style &= ~TVS_LINESATROOT;
    cs.style &= ~TVS_HASBUTTONS;

    // If non-xp mode, add a client edge border to the tree.
    if (!xtAfxData.bXPMode)
    {
        cs.dwExStyle |= WS_EX_CLIENTEDGE;
    }

    cs.style |= TVS_NOTOOLTIPS;

       return TRUE;
}

CString CreateMarkupTool(LPCTSTR strCaption, LPCTSTR strDesc)
{
     
    CString strHTML;
    strHTML.Format(
            _T("<StackPanel Margin='1' MaxWidth='200'>")
                _T("<TextBlock Padding='1, 3, 1, 3' FontWeight='Bold'>%s</TextBlock>")
                _T("<TextBlock Padding='9, 6, 30, 7' TextWrapping='Wrap'>%s</TextBlock>")
                _T("<Border Height='1' Background='#9ebbdd' />")
                _T("<Border Height='1' Background='White' />")               
            _T("</StackPanel>"),
        strCaption, strDesc);
   
    return strHTML;
}

INT_PTR CUIActiveUsersTreeCtrl::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
{
    // check child windows first by calling CControlBar
    INT_PTR nHit = CWnd::OnToolHitTest(point, pTI);
    if (nHit != -1)
        return nHit;

    HTREEITEM hTreeItem = GetItemFromPoint(point); // this is yust a helper to get item under cursor
    if(hTreeItem)
    {
        nHit = (INT_PTR) hTreeItem;
        m_TTContext.FillInToolInfo(pTI, GetSafeHwnd(), CRect(point, CSize(100, 100) ), nHit, CreateMarkupTool(_T("XXX Test"), _T("YYY TEST2")));

        return nHit;
    }
    return -1;
}

void CUIActiveUsersTreeCtrl::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_TTContext.FilterToolTipMessage(this, &msg);
}

BOOL CUIActiveUsersTreeCtrl::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
    //m_TTContext.FilterToolTipMessage(this, message, wParam, lParam);
    if (message == WM_MOUSEMOVE)
        RelayEvent(message, wParam, lParam);

    return CUIXTreeCtrl::OnWndMsg(message, wParam, lParam, pResult);
}


Back to Top
Alex H. View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 February 2004
Status: Offline
Points: 266
Post Options Post Options   Thanks (0) Thanks(0)   Quote Alex H. Quote  Post ReplyReply Direct Link To This Post Posted: 27 October 2010 at 4:20am
Ok it works now :-)

Changed the code in on ToolHitTest

...
 HTREEITEM hTreeItem = HitTest(point, &nFlags);  // GetItemFromPoint(point);
 if(pTI && hTreeItem)
 {
       nHit = reinterpret_cast<INT_PTR>(hTreeItem);

...

Once again - thank you for your help!
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.047 seconds.