Solved

ToolTips w/ TreeView...

Posted on 2000-05-02
2
244 Views
Last Modified: 2010-05-18
Dum qwestion but... Get tool tips to work with CTreeView within CMDIChildWnd...
0
Comment
Question by:muffinthedog
2 Comments
 
LVL 5

Accepted Solution

by:
proskig earned 100 total points
Comment Utility
From codeguru:
Changing the tool tip as the mouse pointer moves along different tree control items is fairly simple. The tree control can be on a dialog, property page or a form view. Assuming that you use a class derived from CFormView called CMyFormView, which has a tree control, the steps to follow are:

Declare a member variable for the tree control (IDC_TREE1), m_tree.
Decide on how the tip for each tree item will be stored. For instance, you could hold the tip in a map which you declare in the header file CMyFormView.h.

      CMap< HTREEITEM,HTREEITEM&,CString,CString& > tooltipMap;
Fill the map as you generate the items of the tree. For instance after every InsertItem:
      HTREEITEM hItem = m_tree.InsertItem(&tvItem); // tvItem is of type TV_INSERTSTRUCT
      tooltipMap[hItem] = " Tool Tip Text   ";   // Set the tool tip text of the item.
      
Declare an object of CToolTipCtrl in the header file CMyFormView .h
      CToolTipCtrl m_tooltip;
Create the tool tip control and initialize it in the OnInitialUpdate message handler (OnInitDialog for CDialog derived classes)
      m_tooltip.Create(this);
      m_tooltip.Activate(TRUE);
      m_tooltip.AddTool(GetDlgItem(IDC_TREE1), "Tree Tool Tip");
      
Override the PreTranslateMessage in the form view.
      BOOL CMyFormView::PreTranslateMessage(MSG* pMsg)
      {
            // TODO: Add your specialized code here and/or call the base class
            if(pMsg->message == WM_MOUSEMOVE && pMsg->hwnd == m_tree.m_hWnd)
            {
            CPoint point(LOWORD(pMsg->lParam),HIWORD(pMsg->lParam));
                  HTREEITEM hItem = m_tree.HitTest(point);
                  if(hItem != NULL)
                  {
                        CString text = tooltipMap[hItem];                        
                        m_tooltip.UpdateTipText(text,&m_tree);
                        m_tooltip.RelayEvent(pMsg);
                  }
                  
            }
      }
      
This changes the tool tip text as the mouse pointer moves along the different items in the tree control.
0
 
LVL 1

Author Comment

by:muffinthedog
Comment Utility
Worked with minor mod for CTreeView...
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
how to import Image file in turbo c++ ? 6 48
best sources to up-to-date in C++? 8 55
C++ question 3 45
Dialogbox API leak? 18 59
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now