am632 Posted March 13, 2015 Share Posted March 13, 2015 Hi, I have a basic slider, with numbers between 1 & 100 and the slider works fine, I click a button which displays a msgbox containing the selected number from the slider control but is there a way I can make the slider show the current number as the user slides up & down - like in a small balloon tip above the slider for example? because the user doesnt know which number is selected until the msgbox is displayed. Thanks Link to comment Share on other sites More sharing options...
jdelaney Posted March 13, 2015 Share Posted March 13, 2015 (edited) The helpfile example shows how to do that: $hSlider = _GUICtrlSlider_Create($hGUI, 2, 2, 396, 20, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS)) Edited March 13, 2015 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
DocTorCoder Posted March 13, 2015 Share Posted March 13, 2015 (edited) Hi, I have a basic slider, with numbers between 1 & 100 and the slider works fine, I click a button which displays a msgbox containing the selected number from the slider control but is there a way I can make the slider show the current number as the user slides up & down - like in a small balloon tip above the slider for example? because the user doesnt know which number is selected until the msgbox is displayed. Thanks you can do something like this while 1 changeslider() sleep(200) Wend Func changeslider() GUICtrlSetData($yourlabel,$yourslidervalue) EndFunc Or: AdlibRegister("changeslider",200) Func changeslider() GUICtrlSetData($yourlabel,$yourslidervalue) EndFunc $yourslidervalue = slider which you created with current value $yourlabel = a label which you will create it and will contain the slider value (put in below slider to look like is a part of slider) Edited March 13, 2015 by DocTorCoder DocTorCoder Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 13, 2015 Moderators Share Posted March 13, 2015 DocTorCoder,Personally, I would wait until the slider was actually moved rather than run the function every time through the loop: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <SliderConstants.au3> #include <WinAPI.au3> Global $nTimer, $bToolTip = False $hGUI = GUICreate("Test", 500, 500) $cSlider = GUICtrlCreateSlider(10, 10, 200, 20, $TBS_AUTOTICKS) $hSlider = GUICtrlGetHandle($cSlider) GUISetState() GUIRegisterMsg($WM_HSCROLL, "_WM_HSCROLL") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; If tooltip displayed and no change for 500ms If $bToolTip And TimerDiff($nTimer) > 500 Then ; Clear tootip ToolTip("") ; Clear flag $bToolTip = False EndIf WEnd ; React to slider movement Func _WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg If $lParam = $hSlider Then If _WinAPI_LoWord($wParam) = 5 Then ;$SB_THUMBTRACK ; Show tooltip ToolTip(GUICtrlRead($cSlider)) ; Set timestamp $nTimer = TimerInit() ; Set flag $bToolTip = True EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_HSCROLLWhen passing through the idle loop the flag is checked and nothing more happens until it is set. That means the slider has been moved and now there is a second check to get the time since the last movement - and then the tooltip is cleared if no movement has taken place for a given time. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
am632 Posted March 13, 2015 Author Share Posted March 13, 2015 Hi, Thanks all for the help, Melba23 your example worked perfectly, Thanks Link to comment Share on other sites More sharing options...
jdelaney Posted March 13, 2015 Share Posted March 13, 2015 (edited) easier route: #include <GuiSlider.au3> #include <GUIConstantsEx.au3> Example() Func Example() GUICreate("slider", 220, 100, 100, 200) GUISetBkColor(0x00E0FFFF) ; will change background color Local $idSlider1 = GUICtrlCreateSlider(10, 10, 200, 20,BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS)) GUICtrlSetLimit(-1, 200, 0) ; change min/max value GUISetState(@SW_SHOW) GUICtrlSetData($idSlider1, 45) ; set cursor Local $idMsg ; Loop until the user exits. Do $idMsg = GUIGetMsg() Until $idMsg = $GUI_EVENT_CLOSE EndFunc ;==>Example Edited March 13, 2015 by jdelaney IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
DocTorCoder Posted March 14, 2015 Share Posted March 14, 2015 DocTorCoder, Personally, I would wait until the slider was actually moved rather than run the function every time through the loop: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <SliderConstants.au3> #include <WinAPI.au3> Global $nTimer, $bToolTip = False $hGUI = GUICreate("Test", 500, 500) $cSlider = GUICtrlCreateSlider(10, 10, 200, 20, $TBS_AUTOTICKS) $hSlider = GUICtrlGetHandle($cSlider) GUISetState() GUIRegisterMsg($WM_HSCROLL, "_WM_HSCROLL") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ; If tooltip displayed and no change for 500ms If $bToolTip And TimerDiff($nTimer) > 500 Then ; Clear tootip ToolTip("") ; Clear flag $bToolTip = False EndIf WEnd ; React to slider movement Func _WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg If $lParam = $hSlider Then If _WinAPI_LoWord($wParam) = 5 Then ;$SB_THUMBTRACK ; Show tooltip ToolTip(GUICtrlRead($cSlider)) ; Set timestamp $nTimer = TimerInit() ; Set flag $bToolTip = True EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>_WM_HSCROLL When passing through the idle loop the flag is checked and nothing more happens until it is set. That means the slider has been moved and now there is a second check to get the time since the last movement - and then the tooltip is cleared if no movement has taken place for a given time. M23 Correct,to avoid doing same thing when moving event is not there! DocTorCoder Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now