TrackBarGadget(): Show tooltip of current value?
Posted: Wed Nov 24, 2010 6:04 pm
I want to display the current value of the trackbar when the user is changing it. Luckily I found the #TBS_TOOLTIPS flag which basically does what I need. However trackbars can't display negative values or floats so I have to calculate the real value of the trackbar state and that's where my problem begins: The tooltip from #TBS_TOOLTIPS obviously doesn't display the calculated value but the trackbar state so instead of "25" it displays "75".
Here is my example code which also uses a normal GadgetToolTip() to show how the #TBS_TOOLTIPS should look like:
Can anyone help me out here?
Here is my example code which also uses a normal GadgetToolTip() to show how the #TBS_TOOLTIPS should look like:
Code: Select all
Enumeration
#Window
#Text
#Trackbar
EndEnumeration
#TBS_TOOLTIPS = $100
If OpenWindow(#Window, 0, 0, 200, 70, "TrackBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
TextGadget(#Text, 10, 10, 180, 20, "Range from -50% to +50%")
TrackBarGadget(#Trackbar, 10, 40, 180, 20, 0, 100, #TBS_TOOLTIPS)
SetGadgetState(#Trackbar, 75) ; Set to "+25%"
Repeat
Select WaitWindowEvent()
Case #PB_Event_Gadget
If EventGadget() = #Trackbar
GadgetToolTip(#Trackbar, Str(GetGadgetState(#Trackbar) - 50) + "%") ; Example how it should look with #TBS_TOOLTIPS
EndIf
Case #PB_Event_CloseWindow
Break
EndSelect
ForEver
EndIf