Solved

CSliderCtrl tooltip

Posted on 2001-07-19
2
888 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
ID: 6298500
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
ID: 6298566
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 94
Macro to save highlighted rows as a separate file 5 41
how to monitor remote shell execution on linux 9 97
format the code in java 6 86
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.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 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

25 Experts available now in Live!

Get 1:1 Help Now