Sign in to follow this  
Followers 0
Justforfun

Slider Help

6 posts in this topic

#1 ·  Posted (edited)

Hello,

I've been trying to make a slider with min\max values from 0 to 100000 but I cant set it above 30000 without it freezing at 0 so my question is if there is no way to set it to 100000 then is there a way to set the guictrlsetlimit to use 0% to 100% where every 1% = 1000 Iwa doing this

$Max = 100000 $Slider1 = GUICtrlCreateSlider(96, 152, 465, 73, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS))
GUICtrlSetLimit($Slider1, $max, 0)
How would I change this to % but still get output value of 100000 or is the away to get pass the 30000 limit I hop I was able to explain this well enough. Edited by Justforfun

Share this post


Link to post
Share on other sites



Justforfun,

Here you go! ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

$hSlider = GUICtrlCreateSlider(10, 10, 480, 30)
$hSlider_Handle = GUICtrlGetHandle($hSlider)
GUICtrlSetLimit($hSlider, 1000, 0) ; 0-1000 here <<<<<<<<<<<<<<<<<<<<<<

$hLabel = GUICtrlCreateLabel("", 10, 100, 200, 20)

GUISetState()

GUIRegisterMsg($WM_HSCROLL, "_Slider_Movement")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Func _Slider_Movement($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $wParam
    If $lParam = $hSlider_Handle Then
        ; Calculate value
        Local $iValue = 100 * GUICtrlRead($hSlider) ; So multiply by 100 here <<<<<<<<<<<<<<<<
        ; Change label
        GUICtrlSetData($hLabel, $iValue)
    EndIf
    Return $GUI_RUNDEFMSG

EndFunc

You can obviously change the Max value and the factor to your own choices.

Ask if anything is unclear. :blink:

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

Justforfun,

Here you go! ;)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

$hSlider = GUICtrlCreateSlider(10, 10, 480, 30)
$hSlider_Handle = GUICtrlGetHandle($hSlider)
GUICtrlSetLimit($hSlider, 1000, 0) ; 0-1000 here <<<<<<<<<<<<<<<<<<<<<<

$hLabel = GUICtrlCreateLabel("", 10, 100, 200, 20)

GUISetState()

GUIRegisterMsg($WM_HSCROLL, "_Slider_Movement")

While 1

    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch

WEnd

Func _Slider_Movement($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $wParam
    If $lParam = $hSlider_Handle Then
        ; Calculate value
        Local $iValue = 100 * GUICtrlRead($hSlider) ; So multiply by 100 here <<<<<<<<<<<<<<<<
        ; Change label
        GUICtrlSetData($hLabel, $iValue)
    EndIf
    Return $GUI_RUNDEFMSG

EndFunc

You can obviously change the Max value and the factor to your own choices.

Ask if anything is unclear. :blink:

M23

You are awesome thanks so very much

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Both the min and max values are packed into a single 32 bit parameter in the message that does the work. So each value is a signed 16-bit integer. That limits you to 32K - 1 for max. The percentage thing is just a little math:

#include <GUIConstantsEx.au3>
#include <SliderConstants.au3>


Global $slider1, $button, $msg, $Max = 2^15 - 1

GUICreate("slider", 400, 300)

$slider1 = GUICtrlCreateSlider(20, 25, 360, 50, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS))
GUICtrlSetLimit($slider1, $Max, 0)

$slider2 = GUICtrlCreateSlider(20, 100, 360, 50, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS))
GUICtrlSetLimit($slider2, $Max + 1, 0)

$slider3 = GUICtrlCreateSlider(20, 175, 360, 50, BitOR($TBS_TOOLTIPS, $TBS_AUTOTICKS))
GUICtrlSetLimit($slider3, 100, 0)

$button = GUICtrlCreateButton("Value?", 150, 250, 100, 30)
GUISetState()

Do
    $msg = GUIGetMsg()

    If $msg = $button Then
        MsgBox(0, "sliders", "Slider1: " & GUICtrlRead($slider1) & @CRLF & _
                "Slider2: " & GUICtrlRead($slider2) & @CRLF & _
                "Slider3: " & GUICtrlRead($slider3) & "% = " & GUICtrlRead($slider3) * 100000 / 100, 5)
    EndIf
Until $msg = $GUI_EVENT_CLOSE

:blink:

Edit: Too slow for the whirly-bird!

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

PsaltyDS,

Thanks for that little bit of info. :blink:

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

#6 ·  Posted (edited)

in $wParam is all needed info:

BitAND($wParam, 0x0000FFFF) will give you the state of the mouse:

while scrolling the slider:

$wParam = 0x001D0005

state: 5

on releasing the mouse:

$wParam = 0x00000008

state: 8

but the first part ("0x001D") contains the value of the slider and thats my question:

how to calculate this value from $wParam to a dec value?

EDIT:

have found the answer by myself:

BitShift($wParam, 16) will give the slider-value.

Edited by Raik

AutoIt-Syntaxsheme for Proton & Phase5 * Firefox Addons by me (resizable Textarea 0.1d) (docked JS-Console 0.1.1)

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
Sign in to follow this  
Followers 0