How to show tool tip for a slider control

Hi all,

In my application, I have a slider control placed on a form view. What I 
want is that when a user moved the pointer of the slider control, i want to 
display the value of the current slider position in a tooltip over the 
slider control. I have written following code for this but it is not 
working. Please tell me what should i do?

void CMyFormView::OnInitialUpdate()
{
  .........
  m_slidertip.Create(&m_slider);  // m_slider is class variable of type 
CSliderCtrl
  strcpy(m_slidertip_text, "Slider");   // char m_slidertip_text[500]
  m_slidertip.AddTool(&m_slider, m_slidertip_text, &rc, IDC_SLIDER1);
  m_slidertip.Activate(true);
  ........
}

BOOL CMyFormView::PreTranslateMessage(MSG* pMsg)
{
 // TODO: Add your specialized code here and/or call the base class
 m_slidertip.RelayEvent(pMsg);
 return CFormView::PreTranslateMessage(pMsg);
}

void CMyFormView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
 // TODO: Add your message handler code here and/or call default
 if((CSliderCtrl *)pScrollBar == &m_slider)
 {
   CString str;
   str.Format("%d", m_slider.GetPos());
   strcpy(m_slidertip_text, str);
  m_slidertip.UpdateTipText(m_slidertip_text, &m_slider, IDC_SLIDER1);
  m_slidertip.Update();
 }
 CFormView::OnHScroll(nSBCode, nPos, pScrollBar);
}

However, I am not getting any tooltip above my slider control. Please tell 
me what should i do?

Thanks,

Arsalan 


0
aah1 (4)
3/15/2005 2:42:32 PM
vc.mfc 33608 articles. 0 followers. Follow

8 Replies
1745 Views

Similar Articles

[PageSpeed] 53

"Arsalan Ahmad" <aah@qosmotec.com> wrote in message
news:%23SjG60WKFHA.1096@tk2msftngp13.phx.gbl...
> Hi all,
>
> In my application, I have a slider control placed on a form view. What I
> want is that when a user moved the pointer of the slider control, i want
to
> display the value of the current slider position in a tooltip over the
> slider control.

TBS_TOOLTIPS...

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/trackbar/styles.asp

-- 
Jeff Partch [VC++ MVP]


0
jeffp (1711)
3/15/2005 3:41:22 PM
Thanks but suppose that based on this current position, i look a table and 
get a string from that table and now i want to show that string then how 
should i proceed??


"Jeff Partch [MVP]" <jeffp@mvps.org> schrieb im Newsbeitrag 
news:%23vr2yVXKFHA.1476@TK2MSFTNGP09.phx.gbl...
> "Arsalan Ahmad" <aah@qosmotec.com> wrote in message
> news:%23SjG60WKFHA.1096@tk2msftngp13.phx.gbl...
>> Hi all,
>>
>> In my application, I have a slider control placed on a form view. What I
>> want is that when a user moved the pointer of the slider control, i want
> to
>> display the value of the current slider position in a tooltip over the
>> slider control.
>
> TBS_TOOLTIPS...
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/trackbar/styles.asp
>
> -- 
> Jeff Partch [VC++ MVP]
>
> 


0
aah1 (4)
3/15/2005 4:48:22 PM
"Arsalan Ahmad" <aah@qosmotec.com> wrote in message
news:%23v0PP7XKFHA.3340@TK2MSFTNGP14.phx.gbl...
> Thanks but suppose that based on this current position, i look a table and
> get a string from that table and now i want to show that string then how
> should i proceed??

I'd try handling the TTN_NEEDTEXT[A/W] notifications in a CSliderCtrl
subclass.
-- 
Jeff Partch [VC++ MVP]


0
jeffp (1711)
3/15/2005 6:26:39 PM
"Jeff Partch [MVP]" wrote:
> I'd try handling the TTN_NEEDTEXT[A/W] notifications in a CSliderCtrl
> subclass.
> -- 
> Jeff Partch [VC++ MVP]
> 
> 
> 

Simply providing handlers for TTN_NEEDTEXT in slider class will not 
guarantee that slider will receive those messages.

Default implementation of OnToolHitTest (CWnd) designates parent window for 
TTN_NEEDTEXT messages.

Arsalan,
You are confusing tool tips into thinking that you are adding rectangle as a 
tool, and that is not a case.
Using m_slidertip_text as buffer is not necessary.

Here are code changes for you:
void CMyFormView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();

	m_slidertip.Create(&m_slider);	

	CRect rect;
	m_slider.GetWindowRect(rect);
	CString csPos;
	csPos.Format("Slider Pos: %d", m_slider.GetPos());


	m_slidertip.AddTool(&m_slider, csPos);
	m_slidertip.Activate(true);
}

void CMyFormView::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
{
	if((CSliderCtrl *)pScrollBar == &m_slider)
	{
		CString str;
		str.Format("Slider Pos: %d", m_slider.GetPos());
	
		m_slidertip.UpdateTipText(str, &m_slider);
	}
	
	CFormView::OnHScroll(nSBCode, nPos, pScrollBar);
}



0
RainMan6256 (150)
3/18/2005 12:03:06 AM
"RainMan" <RainMan@online.nospam> wrote in message
news:017499C4-2801-43CD-8B5D-83C99D800DB7@microsoft.com...
> "Jeff Partch [MVP]" wrote:
> > I'd try handling the TTN_NEEDTEXT[A/W] notifications in a CSliderCtrl
> > subclass.
>
> Simply providing handlers for TTN_NEEDTEXT in slider class will not
> guarantee that slider will receive those messages.

Umm. If a TBS_TOOLTIPS style trackbar creates its TT using
LPSTR_TEXTCALLBACK, and provides the text by responding to this
notification, why wouldn't intercepting it in a subclass be a proper course
of action?
-- 
Jeff Partch [VC++ MVP]


0
jeffp (1711)
3/18/2005 12:34:27 AM
"Jeff Partch [MVP]" wrote:

> Umm. If a TBS_TOOLTIPS style trackbar creates its TT using
> LPSTR_TEXTCALLBACK, and provides the text by responding to this
> notification, why wouldn't intercepting it in a subclass be a proper course
> of action?

I did not state in my post that this would not "be a proper action"; I just 
pointed that:
"Simply providing handlers for TTN_NEEDTEXT in slider class *will not 
guarantee* that slider will receive those messages." 

Maybe I should have been clearer in my previous post:

Following would have to be taken under consideration:

1. Slider would have to be created with TBS_TOOLTIPS style in order to use 
build in tooltips.
2. This style is not present in VS 6.0 modifying style will not create build 
in tool tips, therefore slider would have to be created at the runtime.
3. Default implementation shows slider position only when slider is clicked 
on and/or moving. Providing all of the above is true, handling TTN_NEEDTEXT 
notifications would change tool tip text only when mouse is dragging slider.

Default implementation does not meet Arsalan 's requirements since does not 
handle tooltips when mouse stops over slider. 

In order to achieve this:
1. Arsalan's implementation can be used (with correction).
2. Default CWnd tool tip control could be used in dialog, where 
EnableTooltips has to be called and TTN_NEEDTEXT notification has to be 
handled.
3. Default tool tip could be used in a slider (subclassed using CSliderCtrl 
derived class), where EnableTooltips has to be called, TTN_NEEDTEXT 
notification has to be handled and OnToolHitTest has to be overridden.


0
RainMan6256 (150)
3/18/2005 1:07:04 PM
"RainMan" <RainMan@online.nospam> wrote in message
news:2F54BDCE-27EA-4001-89E0-B18BCD4AE8EA@microsoft.com...
> "Jeff Partch [MVP]" wrote:
>
> > Umm. If a TBS_TOOLTIPS style trackbar creates its TT using
> > LPSTR_TEXTCALLBACK, and provides the text by responding to this
> > notification, why wouldn't intercepting it in a subclass be a proper
course
> > of action?
>
> I did not state in my post that this would not "be a proper action"; I
just
> pointed that:
> "Simply providing handlers for TTN_NEEDTEXT in slider class *will not
> guarantee* that slider will receive those messages."

Okay.

>
> Maybe I should have been clearer in my previous post:
>

Or I.

> Following would have to be taken under consideration:
>
> 1. Slider would have to be created with TBS_TOOLTIPS style in order to use
> build in tooltips.

Yes that was my original suggestion and the context of the follow-up
suggestion to intercept the notification.

> 2. This style is not present in VS 6.0 modifying style will not create
build
> in tool tips, therefore slider would have to be created at the runtime.

Or one can edit the *.rc file to add it. Nonetheless, this is a side issue.
TBS_TOOLTIPS has been established as the context in which this follow-up
suggestion was made.

> 3. Default implementation shows slider position only when slider is
clicked
> on and/or moving. Providing all of the above is true, handling
TTN_NEEDTEXT
> notifications would change tool tip text only when mouse is dragging
slider.
>
> Default implementation does not meet Arsalan 's requirements since does
not
> handle tooltips when mouse stops over slider.

No, Arsalon said, "What I want is that when a user moved the pointer of the
slider control, i want to
display the value of the current slider position in a tooltip over the
slider control".

That is why I originally suggested TBS_TOOLTIPS: it does this exact thing by
default. He then followed up that suggestion by saying, "Thanks but suppose
that based on this current position, i look a table and get a string from
that table and now i want to show that string then how should i proceed??"

Which is why suggested the TTN_NEEDTEXT interception as a follow-up. To
which you replied, "Simply providing handlers for TTN_NEEDTEXT in slider
class *will not guarantee* that slider will receive those messages".

Given the context and progression of the thread at the point you replied to
it, why wouldn't it be guaranteed?

-- 
Jeff Partch [VC++ MVP]


0
jeffp (1711)
3/18/2005 1:56:34 PM
"Jeff Partch [MVP]" wrote:

> No, Arsalon said, "What I want is that when a user moved the pointer of the
> slider control, i want to
> display the value of the current slider position in a tooltip over the
> slider control".
> 

I have might have misinterpreted this.
I have treated "user *moved* the pointer of the slider control" (notice past 
tense) as one event and "display the value of the current slider position in 
a tooltip over the slider control." as another independent event. 

Other words:
Any time cursor is over tracker control, tool tip shows current position of 
the slider.

I think the only person who can clarify this is Arsalon.

0
RainMan6256 (150)
3/18/2005 3:13:03 PM
Reply:

Similar Artilces:

Does exchange control reminders in Outlook?
Greetings. Our network uses Exchange 2003 on a Windows 2000 Server server to administer the company e-mail. We used to use PST files in Outlook 97 to manage the e-mail for users but now we use Outlook 97 and Exchange Mailboxes. One of my users is noting that reminders in Outlook 97 notify him when they're suppose to for all events, but some things he postpones for many weeks for various reasons. Some items have since quit reminding him, even though they are still in his calendar. He has done this for years, and though he probably should change this practice of his, he recalls that rem...

Redeployment Tool
We are building a test enviroment to reload our current 1.2 databases before upgrading to 3.0. The test enviroment is completly separated from production (New domain, servers etc) The test lab replicates our prod with a server for AD 2003, Exchange 2003 and two CRM boxes, one for the DB and one for the actual application. The redeployment tool exports and DB backups from from prod all are done and the DB restored to the test lab. The redeploy tool fails with the following error: 01/20/2006 14:54:59 Database updated succesfully, row count is 329 01/20/2006 14:55:00 Backup BusinessUnitBas...

Problem with tool bar
Hi all, I have an SDI application in which I have added tree view in addition to the form view (which was the original view). The problem is that in the only toolbar IDR_MAINFRAME, there are some buttons which are handled by the form view class. Now the problem is that if the focus is on form view then those buttons get enabled but if the focus is on tree view (if user clicks on tree view) then those buttons get disabled. How can solve this problem? I dont want to implement handlers for those toolbars button in Mainframe class. Thanks, Arsalan Ahmad Arsalan Ahmad wrote: > Hi ...

visible controls
Visible controls In my form the code for making controls visible and invisible does not work. My code is the following: Private Sub Form_Current() If Me![supplierid] = 1 Then Me.RaufGrade.Visible = False Me.RaufCode.Visible = False Me.AralGrade.Visible = True Me.AralCode.Visible = True ElseIf Me![supplierid] = 2 Then Me.AralGrade.Visible = False Me.AralCode.Visible = False Me.RaufGrade.Visible = True Me.RaufCode.Visible = True End If End Sub Why is it so? Is it because the form is continous? How can I make it work? -- Message posted via AccessMonster.com http://www.ac...

Chart does not show up in print preview and wont print?
I have chart that is a workbook page but when I select print preview it does not shown up, only a blank pages comes up. And so it wont print. How can I fix this? I have Office 2007 and I can not select set print area or clear print area, they are shaded out. ...

%20 shows up in document name when doing a save as
I do alot of quotes that I pull up an old document, update with new info, then save as a new document name, leaving the old one as is. Sometimes when I go to save the new document as save as, the spaces in the name of the document are filled with the percentage symbol and 20, %20. Does anyone know how to fix this? ...

ActiveX control and design mode
Hi, is it possible for an activex control to tell the container to invoke the controls design mode? I'm developing an activex control to be used in office, and I would like the control to start in design mode when inserted into powerpoint for instance. Regards Johan ...

Address toolbar will show only one file
With multiple excel files open the address toolbar will only show one of these. It used to show all open files until I downloaded an Office update recommended by Microsoft after I sent off an error report for an Excel bug. Apologies for first message omitted - "appreciate if anyone could help" "Ian Grega" wrote: > With multiple excel files open the address toolbar will only show one of > these. It used to show all open files until I downloaded an Office update > recommended by Microsoft after I sent off an error report for an Excel bug. Ian Assuming you me...

Show more time in weekly view?
Outlook 2007 On default the weekly view is only showing until 4 PM without scrolling down. I know there is a way to let you see into the evening hours also without scrolling. Help please. Thanks... Bob ...

questions on redeployment tool to copy production to test
In our environment, we have production and test CRM systems on two different domains/forest. Both have CRM running right now. Our objective is to refresh the CRM data in the test environment from Production. 1. The guide says that we need to create a new OU before starting the deployment tool. Do we need to create a new OU for our test system again. The OU is already present. What do we need to do to the OU and the users in it already in the test environment? 2. After the deployment wizard step in the document, the next step is Install Microsoft CRM. Do we need this step as it is alr...

copied additional column shows in view but does show on hardcopy
I have an existing spreadsheet and needed to add another column with the same format. I copied it and but when I print a hard copy it is not there. I checked and that column is not hidden. Re-define your print range to include that column? Gord Dibben MS Excel MVP On Tue, 1 Jun 2010 06:51:01 -0700, Patricia W <Patricia W@discussions.microsoft.com> wrote: >I have an existing spreadsheet and needed to add another column with the= same=20 >format. I copied it and but when I print a hard copy it is not there. = I=20 >checked and that column is not hidden...

Linking worksheets and the formula shows up instead of the answer
I am linking between two sheets and the link formula is showing up instead the answer. It could be a few things... #1. The cell is formatted as text. Format|cells|General (or some number variation--just not Text) then hit F2 followed by enter to re-enter the formula #2. You're looking at formulas Tools|options|View tab\ Make sure Formulas isn't checked #3. Maybe a mistake in your formula. Make sure that there is no space before the initial = (equal sign) BalancedSolutions wrote: > > I am linking between two sheets and the link formula is showi...

How do I enter a date in excel without "/" ex. 041504 will show 0.
Excel can't do this without some help. You could look at: http://www.xldynamic.com/source/xld.QDEDownload.html for an addin that can set this up. tj "Amy" wrote: > ...

Disabling / graying out a control at runtime
Hi, I have a control on a modal dialog, that I which to disable when the user does something. How do I do this? EnableWindow(FALSE); -- Regards, Nish [VC++ MVP] http://www.voidnish.com http://blog.voidnish.com "Hamish" <h.dean@xtra.co.nz> wrote in message news:1A25e.16609$1S4.1692401@news.xtra.co.nz... > Hi, I have a control on a modal dialog, that I which to disable when the > user does something. How do I do this? > > look for [EnableWindow] api -- With Regards Alok Gupta Visit me at http://alok.bizhat.com "I Believe ...

Custom Context Menu for Edit Control
Hello all .. I have a control bar class, CTextBar, derived from the child of CControlBar which uses an edit control (CTextEdit derived from CEdit). And i want to create a custom context menu for the edit control with Copy, Selectall and Wordwrap. My wordwrap implementation is kind of not perfect and i feel it could be done better. However, currently i use something like destroying the edit control and recreating it with the right flags set to make the wordwrap effect, as in a notepad. This implementation has a disadvantage because it needs a pointer to its parent window (in this case, the CCo...

Tips & tricks conditional formatting
Tips & tricks conditional formatting I have txtbox1 I do for this text box conditional format Expression Txtbox1=txtbox1 Formating Font:Bold Color: Red This code work very good to color txtbox1 in the subform give me nice idea to color column My Question is: 1-Why this Expression Work Correctly? 2- this code work if there is a value in the text box if there is no value the txtbox1 become white the default !!! My question is how also color the txtbox1 where is no value? Mr. John W. Vinson [MVP] How are you I'm happy to hear from you .. You are really Very good Man ...

backup tool
I can't seem to get this on my computer. i download the software, and install it. it says that it is installed. When i go to file and look for "backup" on the menu, it is not there. i've tried re-installing the tool (the computer says that i have it on the computer, do i want to re-install, i say yes, but still no backup on the menu. Does this happen when you are in a limited user profile of Windows XP? If so you will need to temporarily make the account as Administrator and then install the backup tool and if everything is working, change back the accoun...

Year series shows wrong in chart
Hi all : using Excel 2003, I have what should not even be a problem that I cannot solve. I have a series of years in a column, 1970-2006 to be exact, and these are the labels for my x axis. When I insert chart this appears as 1,2,3,...instead of 1970, 1971, etc. It doesn't matter how I format that column, text, general, custom, nothing works. Why is it not just giving me the data in the format that is actually there and how can I get it? thanks for any help Bevin B. Try first entering the dates as dates. To check to make sure they're entered as dates, after entering the data c...

domain controllers do not appear to be running #2
Hi There are a number of errors when running CRM 3.0 and I have the following error when I run the environment diagnostics check : "Some of the domain controllers do not appear to be running. The following list of servers should be checked. PrivUserGroup {8654dfe6-2d69-4ead-8f86-d49f26814c64} ReportingGroup {8654dfe6-2d69-4ead-8f86-d49f26814c64} SQLAccessGroup {8654dfe6-2d69-4ead-8f86-d49f26814c64} UserGroup {8654dfe6-2d69-4ead-8f86-d49f26814c64} " Does anyone have any suggestions ? If I re-run the setup do I risk losing any data/configuration setting on my current installatio...

i have #name? at my control
i have #name? at my control. I cobined these functions (iif(), left(), right(),count() ,integer() and the concatenation sign(&)) to change numbers into texts on a form . It woked well as i wanted . after a perioud of using my system perfictly I faced this problem. i began trubleshooting to determine the cause . the cases noted by "help" missed the problem .i removed the ms_office and reset it up and checked the refernces and unchecked the microsft missing refernces. but the problem still faceing me . i copied my system in another computer is worked well. them i formated m...

Images in Signature show up as attachments!!
Version: 2008 Operating System: Mac OS X 10.6 (Snow Leopard) Processor: Intel Email Client: imap I am a new PC-to-Mac user and so bear with me if I am asking a question that has been answered (at least I couldn't find one). <br><br>Anyways, I am using Entourage 2008 and I am seeing images in a signature showing up as attachments!! Is this normal? Didn't see the same with Outlook 2007. <br><br>The real problem is &quot;How to differentiate emails with real attachments Vs these signature image attachments?&quot; <br><br>Thanking you in ad...

Unhide (show) Outlook Bar
At work I use Microsoft Exchange 2000 Server Outlook Web Access for email. I have hidden the Outlook Bar and cannot find out how to unhide (show) it. This means that I cannot read my deleted messages before dumping them. How do I unhide the Outlook Bar? Ask in an Exchange group as Outlook Web Access is a function of Exchange, not Outlook. --� Milly Staples [MVP - Outlook] Post all replies to the group to keep the discussion intact. Due to the (insert latest virus name here) virus, all mail sent to my personal account will be deleted without reading. After searching google.groups.co...

Re: property page with COM control inside .dll does not work!
Hi, Alexander sorry I made a mistake, I meen "make the property page a COM control". But this seems too hard for me. Now I am trying to put the dialog resource in a dll and load it to CMyPropertyPage later in another application. I have made the dll with success but this property page cannot be shown in the property sheet just like before. My code seems like this: the dll is named TeRes.dll, and in another application: CPropertyPage* makePropertyPage(bool flag) { CPropertyPage* p; if(flag) { HINSTANCE hDll =3D LoadLibrary("TeRes.dll"); if(hDll...

chart to show employee requests during a given year
I am not very familar with charts or graphs. I would like to create a chart that will track employee requests off during a given year. I need it for excell 2003 any help would be appriciated thanks! ...

Show shape on cell select, Hide shape when cell is deselected
How can the sub below be modified to a sheet level code that works like the pop-up DV input message (ie when DV cell is selected, the input message will show)? Or any other sub which can give the same functionality - when cell (within a defined range on the sheet) is selected, show the shape "txt1", when cell is deselected, hide the shape? Thanks Sub T_Box1() If ActiveSheet.Shapes("txt1").Visible = False Then ActiveSheet.Shapes("txt1").Visible = True Else ActiveSheet.Shapes("txt1").Visible = False End If End ...