weirddave 0 Posted April 1, 2015 I'm using a slider to access data packets in a file. The number of packets is variable, I've had over 1M. I'm using: GUICtrlSetLimit ($idSliderReplay, $FilePackets-1, 0) to set the slider limits. However, when I return the current slider position using: $FilePos = GUICtrlRead($idSliderReplay) msgbox(0,$FilePackets-1,$FilePos) I get 30599 returned (the msgbox shows 12575784 in the title) when I slide all the way to the right. The optimum would probably be to set the slider limit to the number of pixels it can slide along, but I don't see a way to find that out. Then I would just multiply the slider position by $FilePackets/$SliderPixels to get my position. Any thoughts? Share this post Link to post Share on other sites
Bert 1,372 Posted April 1, 2015 why use a slider? why not use a picklist? Hide Bert's signature Hide all signatures The Vollatran project _____ I'm famous My blog: http://www.vollysinterestingshit.com/ Share this post Link to post Share on other sites
weirddave 0 Posted April 1, 2015 Not entirely sure what a pick list is? Will it scale well from small numbers to millions? Share this post Link to post Share on other sites
Melba23 3,080 Posted April 1, 2015 weirddave,Native sliders, and the GUICtrlSetLimit function, are limited to a maximum of 32767 - this is a Windows limitation and nothing to do with AutoIt. Try increasing the value here as see what happens: #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cSlider = GUICtrlCreateSlider(10, 10, 300, 20) GUICtrlSetLimit($cSlider, 32767, 0) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $cButton = GUICtrlCreateButton("Read", 10, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton $iValue = GUICtrlRead($cSlider) MsgBox($MB_SYSTEMMODAL, "Slider", $iValue) EndSwitch WEndBut all is not lost - we can send a message to the slider to increase the maximum - but this comes with some disadvantages as we will see when we try:#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <SliderConstants.au3> $hGUI = GUICreate("Test", 500, 500) $cSlider = GUICtrlCreateSlider(10, 10, 300, 20) GUICtrlSendMsg($cSlider, $TBM_SETRANGEMAX, True, 12575784) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $cButton = GUICtrlCreateButton("Read", 10, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton $iValue = GUICtrlRead($cSlider) MsgBox($MB_SYSTEMMODAL, "Slider", $iValue) EndSwitch WEndI certainly get the correct maximum value returned, but the slider is very sluggish - no doubt because it has to do a fair bit of behind the scenes work to calculate the correct value as the thumb is moved. >I would strongly suggest sticking to a more sensible maximum value and doing the maths yourself to get the position:#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> ; Determine the value increment for each slider unit - the default is 100 $iFactor = 12575784 / 100 $hGUI = GUICreate("Test", 500, 500) $cSlider = GUICtrlCreateSlider(10, 10, 300, 20) $cButton = GUICtrlCreateButton("Read", 10, 100, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cButton ; Calculate the value to return $iValue = int(GUICtrlRead($cSlider) * $iFactor) MsgBox($MB_SYSTEMMODAL, "Slider", $iValue) EndSwitch WEndWill that do? M23 Hide Melba23's signature Hide all signatures 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 Share this post Link to post Share on other sites
weirddave 0 Posted April 1, 2015 Ah, so that's the limit, I think doing the maths myself will have to do, ta I will probably use 0 to 9999 so that no matter the slider size (within reason ), the result will stay relatively smooth and linear and not go granular. Share this post Link to post Share on other sites