Solved

CSliderCtrl tooltip

Posted on 2001-07-19
2
859 Views
Last Modified: 2013-11-20

I have derived CSliderNew from CSliderCtrl that can handle both integer and decimal numbers. I would like to know how to replace the CSliderCtrl's tooltip for decimal numbers? Is there a way to intercept the tooltip event and change its text string?
0
Comment
Question by:rrashedi
2 Comments
 
LVL 9

Expert Comment

by:ShaunWilde
Comment Utility
you can get the tooltipctrl using GetToolTips from there you may be able to change the tip text
0
 
LVL 12

Accepted Solution

by:
migel earned 291 total points
Comment Utility
Hi!
you can handle TTN_ notifications from tooltip:
for example:
in the class CMySliderCtrl add this:

virtual BOOL OnNotify(WPARAM wParam, LPARAM, LRESULT* pResult);
// and implmentation
BOOL CMySliderCtrl::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
     NMHDR* pnmh = (NMHDR*)lParam;
     *pResult = TRUE;
     static bool bReentrant = false;
     if (pnmh->code == TTN_SHOW && !bReentrant)
          {
          bReentrant = true;
          char szText[80] = "";
          TOOLINFO ti;
          memset(&ti, 0, sizeof(ti));
          ti.cbSize = sizeof(ti);

          ::SendMessage(pnmh->hwndFrom, TTM_ENUMTOOLS, 0, (LPARAM)&ti );
          //::SendMessage(pnmh->hwndFrom, TTM_GETTOOLINFO, 0, (LPARAM)&ti);
          ti.hinst = AfxGetInstanceHandle();
          ti.lpszText = szText;
          int nPos = SendMessage(TBM_GETPOS);
          sprintf(szText, "%4d.0", nPos); // just add zero after decimal point.
// you can implement your own formatting
          ::SendMessage(pnmh->hwndFrom, TTM_UPDATETIPTEXT, 0, (LPARAM)&ti);
          bReentrant = false;
          return TRUE;
          }
     return CSliderCtrl::OnNotify(wParam, lParam, pResult);
}
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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

7 Experts available now in Live!

Get 1:1 Help Now