Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 218411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:44:54+00:00 2026-05-11T18:44:54+00:00

I have a class derived from CTreeCtrl . In OnCreate() I replace the default

  • 0

I have a class derived from CTreeCtrl. In OnCreate() I replace the default CToolTipCtrl object with a custom one:

int CMyTreeCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
    if (CTreeCtrl::OnCreate(lpCreateStruct) == -1)
        return -1;

    // Replace tool tip with our own which will
    // ask us for the text to display with a TTN_NEEDTEXT message
    CTooltipManager::CreateToolTip(m_pToolTip, this, AFX_TOOLTIP_TYPE_DEFAULT);
    m_pToolTip->AddTool(this, LPSTR_TEXTCALLBACK);
    SetToolTips(m_pToolTip);

    // Update: Added these two lines, which don't help either
    m_pToolTip->Activate(TRUE);
    EnableToolTips(TRUE);
    
    return 0;
}

My message handler looks like this:

ON_NOTIFY_EX(TTN_NEEDTEXT, 0, &CMyTreeCtrl::OnTtnNeedText)

However I never receive a TTN_NEEDTEXT message. I had a look with Spy++ and it also looks like this message never gets sent.

What could be the problem here?

Update

I’m not sure whether this is relevant: The CTreeCtrl‘s parent window is of type CDockablePane. Could there be some extra work needed for this to work?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:44:54+00:00Added an answer on May 11, 2026 at 6:44 pm

    Finally! I (partially) solved it:

    It looks like the CDockablePane parent window indeed caused this problem…

    First I removed all the tooltip-specific code from the CTreeCtrl-derived class. Everything is done in the parent pane window.

    Then I edited the parent window’s OnCreate() method:

    int CMyPane::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
        if (CDockablePane::OnCreate(lpCreateStruct) == -1)
            return -1;
    
    const DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN |
        TVS_CHECKBOXES | TVS_DISABLEDRAGDROP | TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT |
        TVS_INFOTIP | TVS_NOHSCROLL | TVS_SHOWSELALWAYS;
    
    // TREECTRL_ID is a custom member constant, set to 1
    if(!m_tree.Create(dwStyle, m_treeRect, this, TREECTRL_ID ) )
    {
        TRACE0("Failed to create trace tree list control.\n");
        return -1;
    }
    
    // m_pToolTip is a protected member of CDockablePane
    m_pToolTip->AddTool(&m_tree, LPSTR_TEXTCALLBACK, &m_treeRect, TREECTRL_ID);
    m_tree.SetToolTips(m_pToolTip);
    
    
    return 0;
    

    }

    Unforunately we cannot simply call AddTool() with less parameters because the base class will complain in the form of an ASSERT about a uFlag member if there is no tool ID set.
    And since we need to set the ID, we also need to set a rectangle. I created a CRect member and set it to (0, 0, 10000, 10000) in the CTor. I have not yet found a working way to change the tool’s rect size so this is my very ugly workaround. This is also why I call this solution partial. Update: I asked a question regarding this.

    Finally there is the handler to get the tooltip info:

    // Message map entry
    ON_NOTIFY(TVN_GETINFOTIP, TREECTRL_ID, &CMobileCatalogPane::OnTvnGetInfoTip)
    
    
    // Handler
    void CMyPane::OnTvnGetInfoTip(NMHDR *pNMHDR, LRESULT *pResult)
    {
        LPNMTVGETINFOTIP pGetInfoTip = reinterpret_cast<LPNMTVGETINFOTIP>(pNMHDR);
    
        // This is a CString member
        m_toolTipText.ReleaseBuffer();
        m_toolTipText.Empty();
    
        // Set your text here...
    
        pGetInfoTip->pszText = m_toolTipText.GetBuffer();
    
        *pResult = 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 105k
  • Answers 105k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Short answer: SQL 2k5/2k8 How to: Increase the Size of… May 11, 2026 at 8:43 pm
  • Editorial Team
    Editorial Team added an answer Besides exception handling... You should reselect the data from the… May 11, 2026 at 8:43 pm
  • Editorial Team
    Editorial Team added an answer Here’s the JavaScript equivalent: var i = null; var j… May 11, 2026 at 8:43 pm

Related Questions

I am looking for a C# example implementation of a class derived from Microsoft's
I have a base class Node which contains a list of child nodes. Node
I have a solution that contains two projects. One project is an ASP.NET Web
How do I call the parent function from a derived class using C++? For
I have a base class Foo that has an Update() function, which I want

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.