Solved

CSliderCtrl tooltip

Posted on 2001-07-19
2
964 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Strange date stored 22 175
Expand LInux Boot partition remotly 3 102
only14 challenge 19 84
no14 challenge 14 73
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…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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