TrackBarGadget(): Show tooltip of current value?

Just starting out? Need help? Post your questions and find answers here.
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

TrackBarGadget(): Show tooltip of current value?

Post by c4s »

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:

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
Can anyone help me out here?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: TrackBarGadget(): Show tooltip of current value?

Post by IdeasVacuum »

Nice sample code. TBM_SETTOOLTIPS might let you replace the default tooltips with your own:

http://msdn.microsoft.com/en-us/library ... 85%29.aspx
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: TrackBarGadget(): Show tooltip of current value?

Post by RASHAD »

Tested with PB x86 win 7 x64

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,0, #TBS_TOOLTIPS)
   SendMessage_(GadgetID(#Trackbar),#TBM_SETRANGEMIN,1,-50)
   SendMessage_(GadgetID(#Trackbar),#TBM_SETRANGEMAX,1,50)
   SetGadgetState(#Trackbar, 0)  ; 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
Egypt my love
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: TrackBarGadget(): Show tooltip of current value?

Post by c4s »

@IdeasVacuum
Hm, I already saw this message but I'm not sure how to use it.

@RASHAD
That's interesting. I think I read in MSDN that the values can only be from 0 to 16000 or something.
Anyway I want to display other text and floats as well so that I could display for example "-25.6%".
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: TrackBarGadget(): Show tooltip of current value?

Post by c4s »

Ok, I tested a little around but it doesn't seem to work: Edit:
Looks better now (tooltip gets displayed), however just for the first moving of the trackbar. All following movements don't display a tooltip at all.

Code: Select all

Enumeration
	#Window
	#Text
	#Trackbar
EndEnumeration

#TBS_TOOLTIPS = $100
#TBM_SETTOOLTIPS = $41D  ;#WM_USER + 29
#TTF_ABSOLUTE = $80
#TTF_TRACK = $20


Define TooltipID, TI.TOOLINFO
Define Text.s


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)


	TooltipID = CreateWindowEx_(0, "ToolTips_Class32", "", 0, 0, 0, 0, 0, WindowID(#Window), 0, GetModuleHandle_(0), 0)
	TI\cbSize = SizeOf(TOOLINFO)
	TI\hWnd = WindowID(#Window)
	TI\uFlags = #TTF_SUBCLASS | #TTF_IDISHWND | #TTF_TRACK
	TI\uId = GadgetID(#Trackbar)
	TI\lpszText = @"0%"  ;
	SendMessage_(TooltipID, #TTM_ADDTOOL, 0, @TI)
	SendMessage_(TooltipID, #TTM_TRACKACTIVATE, #True, @TI)

	SendMessage_(GadgetID(#Trackbar), #TBM_SETTOOLTIPS, TooltipID, 0)

	Repeat
		Select WaitWindowEvent()
			Case #PB_Event_Gadget
				If EventGadget() = #Trackbar
					Text = Str(GetGadgetState(#Trackbar) - 50) + "%"
					TI\cbSize = SizeOf(TOOLINFO)
					TI\hWnd = WindowID(#Window)
					TI\uId = GadgetID(#Trackbar)
					TI\lpszText = @Text
					SendMessage_(TooltipID, #TTM_UPDATETIPTEXT, 0, @TI)
				EndIf
			Case #PB_Event_CloseWindow
				Break
		EndSelect
	ForEver
EndIf
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: TrackBarGadget(): Show tooltip of current value?

Post by RASHAD »

Nice one c4s
See next looks nice too

Code: Select all

Enumeration
   #Window
   #Text
   #Trackbar
EndEnumeration


If OpenWindow(#Window, 0, 0, 200, 70, "TrackBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   TextGadget(#Text, 75, 15, 45, 20, "c4s",#SS_CENTERIMAGE | #SS_CENTER| #WS_BORDER)
   SetGadgetColor(#Text,#PB_Gadget_BackColor,$CEFFFF)
   SetGadgetColor(#Text,#PB_Gadget_FrontColor,$0002FF)
   TrackBarGadget(#Trackbar, 10, 40, 180, 20, 0,0)
   SendMessage_(GadgetID(#Trackbar),#TBM_SETRANGEMIN,1,-50)
   SendMessage_(GadgetID(#Trackbar),#TBM_SETRANGEMAX,1,50)
   SetGadgetState(#Trackbar, 0)  ; Set to "+25%"
   Repeat
      Select WaitWindowEvent()
         Case #PB_Event_Gadget
            pos = SendMessage_(GadgetID(#Trackbar),#TBM_GETPOS,0,0)
            SetGadgetText(#Text,Str(pos)+".00%")
            ResizeGadget(#Text,pos + 80,15,45,20)         
;             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

Egypt my love
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: TrackBarGadget(): Show tooltip of current value?

Post by c4s »

Good idea Rashad but I want to have the real tooltip style and I need the space around the trackbar. That's why I'm still playing around with it and it's getting better but is still very buggy (tooltip sometimes appear on screen border, won't get deleted, just a click on the bar isn't captured etc.). Here is my current code:

Code: Select all

Enumeration
	#Window
	#Text
	#Trackbar
EndEnumeration

#TBM_SETTOOLTIPS = #WM_USER + 29
#TTF_TRACK = $20


Define TooltipID, TI.TOOLINFO
Define Text.s

Procedure CursorOverGadget(WindowNr, GadgetNr)
	Protected CursorX, CursorY
	Protected X, Y, Width, Height
	Protected Result = #False

	If IsWindow(WindowNr)
		CursorX = WindowMouseX(WindowNr)
		CursorY = WindowMouseY(WindowNr)
	EndIf

	If IsGadget(GadgetNr)
		X = GadgetX(GadgetNr)
		Y = GadgetY(GadgetNr)
		Width = GadgetWidth(GadgetNr)
		Height = GadgetHeight(GadgetNr)
	EndIf


	If CursorX >= X And CursorX <= X + Width
		If CursorY >= Y And CursorY <= Y + Height
			Result = #True
		EndIf
	EndIf

	ProcedureReturn Result
EndProcedure


If OpenWindow(#Window, 0, 0, 200, 70, "TrackBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	TextGadget(#Text, 10, 10, 180, 20, "Range from -5.0% to +5.0%")
	TrackBarGadget(#Trackbar, 10, 40, 180, 20, 0, 100)


	Repeat
		Select WaitWindowEvent()
			Case #PB_Event_Gadget
				If EventGadget() = #Trackbar
					Text = StrF((GetGadgetState(#Trackbar) - 50) / 10.0, 1) + "%"
					TI\cbSize = SizeOf(TOOLINFO)
					TI\hWnd = WindowID(#Window)
					TI\uId = GadgetID(#Trackbar)
					TI\lpszText = @Text
					SendMessage_(TooltipID, #TTM_UPDATETIPTEXT, 0, @TI)
					SendMessage_(TooltipID, #TTM_TRACKACTIVATE, #True, @TI)
Debug "tt update"
				EndIf
			Case #WM_LBUTTONDOWN
				If CursorOverGadget(#Window, #Trackbar) = #True
					TooltipID = CreateWindowEx_(0, "ToolTips_Class32", "", #TTS_NOPREFIX, 0, 0, 0, 0, WindowID(#Window), 0, GetModuleHandle_(0), 0)
					TI\cbSize = SizeOf(TOOLINFO)
					TI\hWnd = WindowID(#Window)
					TI\uFlags = #TTF_IDISHWND | #TTF_TRACK | #TTF_CENTERTIP
					TI\uId = GadgetID(#Trackbar)
					SendMessage_(TooltipID, #TTM_ADDTOOL, 0, @TI)
					SendMessage_(GadgetID(#Trackbar), #TBM_SETTOOLTIPS, TooltipID, 0)
Debug "tt create"
				EndIf
			Case #WM_LBUTTONUP
				If CursorOverGadget(#Window, #Trackbar) = #True
					SendMessage_(TooltipID, #TTM_TRACKACTIVATE, #False, @TI)
					SendMessage_(TooltipID, #TTM_DELTOOL, 0, @TI)
Debug "tt delete"
				EndIf
			Case #PB_Event_CloseWindow
				Break
		EndSelect
	ForEver
EndIf
If any (API) Guru knows what I'm doing wrong, please tell me.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: TrackBarGadget(): Show tooltip of current value?

Post by RASHAD »

I hope it works as per your needs

Code: Select all

Enumeration
   #Window
   #Text
   #Trackbar
EndEnumeration

#TBM_SETTOOLTIPS = #WM_USER + 29
#TTF_TRACK = $20


Define TooltipID, TI.TOOLINFO
Define Text.s

Procedure CursorOverGadget(WindowNr, GadgetNr)
   Protected CursorX, CursorY
   Protected X, Y, Width, Height
   Protected Result = #False

   If IsWindow(WindowNr)
      CursorX = WindowMouseX(WindowNr)
      CursorY = WindowMouseY(WindowNr)
   EndIf

   If IsGadget(GadgetNr)
      X = GadgetX(GadgetNr)
      Y = GadgetY(GadgetNr)
      Width = GadgetWidth(GadgetNr)
      Height = GadgetHeight(GadgetNr)
   EndIf


   If CursorX >= X And CursorX <= X + Width
      If CursorY >= Y And CursorY <= Y + Height
         Result = #True
      EndIf
   EndIf

   ProcedureReturn Result
EndProcedure


If OpenWindow(#Window, 0, 0, 200, 70, "TrackBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   TextGadget(#Text, 10, 10, 180, 20, "Range from -5.0% to +5.0%")
   TrackBarGadget(#Trackbar, 10, 40, 180, 20, 0, 100)
   TooltipID = CreateWindowEx_(0, "ToolTips_Class32", "", #TTS_NOPREFIX, 0, 0, 0, 0, WindowID(#Window), 0, GetModuleHandle_(0), 0)
               TI\cbSize = SizeOf(TOOLINFO)
               TI\hWnd = WindowID(#Window)
               TI\uFlags = #TTF_IDISHWND | #TTF_TRACK | #TTF_CENTERTIP
               TI\uId = GadgetID(#Trackbar)
               SendMessage_(GadgetID(#Trackbar), #TBM_SETTOOLTIPS, TooltipID, 0)
   Repeat
         
      Select WaitWindowEvent()
         Case #PB_Event_Gadget
            If EventGadget() = #Trackbar
               Text = StrF((GetGadgetState(#Trackbar) - 50) / 10.0, 1) + "%"
               TI\lpszText = @Text
               TI\uFlags = #TTF_IDISHWND | #TTF_TRACK | #TTF_CENTERTIP
               SendMessage_(TooltipID, #TTM_UPDATETIPTEXT, 0, @TI)
               SendMessage_(TooltipID, #TTM_TRACKACTIVATE, #True, @TI)
            EndIf
         Case #WM_LBUTTONDOWN
               GetCursorPos_(@p.POINT)
            If CursorOverGadget(#Window, #Trackbar) = #True
               SendMessage_(TooltipID, #TTM_ADDTOOL, 0, @TI)
               SendMessage_(TooltipID, #TTM_TRACKPOSITION , 0,PeekQ(@p))
               SendMessage_(TooltipID, #TTM_TRACKACTIVATE, 0, @TI)
            EndIf

         Case #WM_LBUTTONUP
               SendMessage_(TooltipID, #TTM_TRACKACTIVATE, 1, @TI)
               Delay(500)
               SendMessage_(TooltipID, #TTM_DELTOOL, 0, @TI)
         Case #PB_Event_CloseWindow
            Break
      EndSelect
   ForEver
EndIf
Edit:Updated
Last edited by RASHAD on Thu Nov 25, 2010 4:30 pm, edited 1 time in total.
Egypt my love
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: TrackBarGadget(): Show tooltip of current value?

Post by c4s »

Thank you very much Rashad, much better now!

There still is a bug when I just click on the area where the track button isn't located: Using it the first time the tooltip will appear on the screen border and after it at the outdated position -> move the window and then click somewhere the track button isn't to see what I mean.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: TrackBarGadget(): Show tooltip of current value?

Post by RASHAD »

@c4s Hi
I just updated my previous post
Egypt my love
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: TrackBarGadget(): Show tooltip of current value?

Post by c4s »

Now the clicked tooltip is under the trackbar and the normal one above the cursor (as it should be)...this tooltip stuff drives me crazy because it doesn't make any sense. :x

Anyway, thanks for helping so far, Rashad!
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: TrackBarGadget(): Show tooltip of current value?

Post by RASHAD »

@c4s I thought you will like it that way
OK
#1: Taking the position of the cursor into consideration
change:

Code: Select all

SendMessage_(TooltipID, #TTM_TRACKPOSITION , 0,PeekQ(@p))
To:

Code: Select all

SendMessage_(TooltipID, #TTM_TRACKPOSITION , 0,(p\y<<20+p\x))
Edit :
#2: Taking the position of the thump into consideration
change:

Code: Select all

         Case #WM_LBUTTONDOWN
;                GetCursorPos_(@p.POINT)
;                Debug p\x
;                Debug p\y
               GetWindowRect_(GadgetID(#Trackbar),r2.RECT)
               SendMessage_(GadgetID(#Trackbar), #TBM_GETTHUMBRECT, 0, r.RECT)
            If CursorOverGadget(#Window, #Trackbar) = #True
               SendMessage_(TooltipID, #TTM_ADDTOOL, 0, @TI)
               SendMessage_(TooltipID, #TTM_TRACKPOSITION , 0,((r2\top+r\top)<<20+(r2\left+r\left)))
               SendMessage_(TooltipID, #TTM_TRACKACTIVATE, 0, @TI)
            EndIf
Egypt my love
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: TrackBarGadget(): Show tooltip of current value?

Post by c4s »

This "<<20" seems to be the final touch I needed, you are my hero! :wink:
Rashad, thanks again for your great help.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: TrackBarGadget(): Show tooltip of current value?

Post by c4s »

Is it also possible to show the trackbar-tooltip when the cursor is just hovering over the gadget, like a regular tooltip but at the same position, size of the trackbar one and showing immediately?

The code I'm using right now:

Code: Select all

Enumeration
	#Window
	#Text
	#Trackbar
EndEnumeration

#TBM_SETTOOLTIPS = #WM_USER + 29
#TTF_TRACK = $20


Define TooltipID, ti.TOOLINFO
Define Text.s

Procedure CursorOverGadget(WindowNr, GadgetNr)
	Protected CursorX, CursorY
	Protected X, Y, Width, Height
	Protected Result = #False

	If IsWindow(WindowNr)
		CursorX = WindowMouseX(WindowNr)
		CursorY = WindowMouseY(WindowNr)
	EndIf

	If IsGadget(GadgetNr)
		X = GadgetX(GadgetNr)
		Y = GadgetY(GadgetNr)
		Width = GadgetWidth(GadgetNr)
		Height = GadgetHeight(GadgetNr)
	EndIf


	If CursorX >= X And CursorX <= X + Width
		If CursorY >= Y And CursorY <= Y + Height
			Result = #True
		EndIf
	EndIf

	ProcedureReturn Result
EndProcedure


If OpenWindow(#Window, 0, 0, 200, 70, "TrackBar Tooltip", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
	TextGadget(#Text, 10, 10, 180, 20, "Range from -5.0% to +5.0%")
	TrackBarGadget(#Trackbar, 10, 40, 180, 20, 0, 100)

	TooltipID = CreateWindowEx_(0, #TOOLTIPS_CLASS, "", #TTS_NOPREFIX, 0, 0, 0, 0, WindowID(#Window), 0, GetModuleHandle_(0), 0)
	ti\cbSize = SizeOf(TOOLINFO)
	ti\hWnd = WindowID(#Window)
	ti\uFlags = #TTF_IDISHWND | #TTF_TRACK | #TTF_CENTERTIP
	ti\uId = GadgetID(#Trackbar)
	SendMessage_(GadgetID(#Trackbar), #TBM_SETTOOLTIPS, TooltipID, 0)


	Repeat
		Select WaitWindowEvent()
			Case #PB_Event_Gadget
				If EventGadget() = #Trackbar
					Text = StrF((GetGadgetState(#Trackbar) - 50) / 10.0, 1) + "%"
					ti\lpszText = @Text
					SendMessage_(TooltipID, #TTM_UPDATETIPTEXT, 0, @ti)
					SendMessage_(TooltipID, #TTM_TRACKACTIVATE, #True, @ti)
				EndIf

			Case #WM_LBUTTONDOWN
				GetCursorPos_(@p.POINT)
				If CursorOverGadget(#Window, #Trackbar) = #True
					SendMessage_(TooltipID, #TTM_ADDTOOL, 0, @ti)
					SendMessage_(TooltipID, #TTM_TRACKPOSITION, 0, (p\y << 20 + p\x))
					SendMessage_(TooltipID, #TTM_TRACKACTIVATE, #False, @ti)
				EndIf

			Case #WM_LBUTTONUP
				SendMessage_(TooltipID, #TTM_TRACKACTIVATE, #True, @ti)
				SendMessage_(TooltipID, #TTM_DELTOOL, 0, @ti)

			Case #PB_Event_CloseWindow
				Break
		EndSelect
	ForEver
EndIf
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4954
Joined: Sun Apr 12, 2009 6:27 am

Re: TrackBarGadget(): Show tooltip of current value?

Post by RASHAD »

I just played a little with the code
See if you can adapt it for your needs

Code: Select all

Enumeration
   #Window
   #Text
   #Trackbar
EndEnumeration

#TBM_SETTOOLTIPS = #WM_USER + 29
#TTF_TRACK = $20


Define TooltipID, ti.TOOLINFO
Define Text.s

Procedure CursorOverGadget(WindowNr, GadgetNr)
   Protected CursorX, CursorY
   Protected X, Y, Width, Height
   Protected Result = #False

   If IsWindow(WindowNr)
      CursorX = WindowMouseX(WindowNr)
      CursorY = WindowMouseY(WindowNr)
   EndIf

   If IsGadget(GadgetNr)
      X = GadgetX(GadgetNr)
      Y = GadgetY(GadgetNr)
      Width = GadgetWidth(GadgetNr)
      Height = GadgetHeight(GadgetNr)
   EndIf


   If CursorX >= X And CursorX <= X + Width
      If CursorY >= Y And CursorY <= Y + Height
         Result = #True
      EndIf
   EndIf

   ProcedureReturn Result
EndProcedure


If OpenWindow(#Window, 0, 0, 200, 70, "TrackBar Tooltip", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
   TextGadget(#Text, 10, 10, 180, 20, "Range from -82.0% to +82.0%")
   TrackBarGadget(#Trackbar, 10, 40, 180, 20, 0, 100)

   TooltipID = CreateWindowEx_(0, #TOOLTIPS_CLASS, "", #TTS_NOPREFIX, 0, 0, 0, 0, WindowID(#Window), 0, GetModuleHandle_(0), 0)
   ti\cbSize = SizeOf(TOOLINFO)
   ti\hWnd = WindowID(#Window)
   ti\uFlags = #TTF_IDISHWND | #TTF_TRACK | #TTF_CENTERTIP
   ti\uId = GadgetID(#Trackbar)
   SendMessage_(GadgetID(#Trackbar), #TBM_SETTOOLTIPS, TooltipID, 0)


   Repeat
      Select WaitWindowEvent()
;          Case #PB_Event_Gadget
;             If EventGadget() = #Trackbar
;                Text = StrF((GetGadgetState(#Trackbar) - 50) / 10.0, 1) + "%"
;                ti\lpszText = @Text
;                SendMessage_(TooltipID, #TTM_UPDATETIPTEXT, 0, @ti)
;                SendMessage_(TooltipID, #TTM_TRACKACTIVATE, #True, @ti)
;             EndIf
; 
;          Case #WM_LBUTTONDOWN
;             GetCursorPos_(@p.POINT)
;             If CursorOverGadget(#Window, #Trackbar) = #True
;                SendMessage_(TooltipID, #TTM_ADDTOOL, 0, @ti)
;                SendMessage_(TooltipID, #TTM_TRACKPOSITION, 0, (p\y << 20 + p\x))
;                SendMessage_(TooltipID, #TTM_TRACKACTIVATE, #False, @ti)
;             EndIf

         Case #WM_LBUTTONUP
            SendMessage_(TooltipID, #TTM_TRACKACTIVATE, #True, @ti)
            SendMessage_(TooltipID, #TTM_DELTOOL, 0, @ti)
            
         Case #WM_MOUSEMOVE
            GetWindowRect_(GadgetID(#Trackbar),r.RECT)
            GetCursorPos_(@p.POINT)
            If CursorOverGadget(#Window, #Trackbar) = #True
               Text = Str(p\x - r\left - 90) + "%"
               ti\lpszText = @Text
               SendMessage_(TooltipID, #TTM_UPDATETIPTEXT, 0, @ti)
               SendMessage_(TooltipID, #TTM_TRACKACTIVATE, #True, @ti)
               SendMessage_(TooltipID, #TTM_ADDTOOL, 0, @ti)
               SendMessage_(TooltipID, #TTM_TRACKPOSITION, 0, (p\y << 20 + p\x))
               SendMessage_(TooltipID, #TTM_TRACKACTIVATE, #False, @ti)
            EndIf

         Case #PB_Event_CloseWindow
            Break
      EndSelect
   ForEver
EndIf

Egypt my love
Post Reply