Solved

CSliderCtrl tooltip

Posted on 2001-07-19
2
938 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
deburging in oracle form 12 104
Doc'in system (example?) BA 7 115
NotAlone Challenge 20 84
Capture logon name 13 87
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

808 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