weirddave

Do Slider limits have maximum values?

5 posts in this topic

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



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

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
WEnd
But 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
WEnd
I 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
WEnd
Will that do? :huh:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

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

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 account

Sign in

Already have an account? Sign in here.


Sign In Now