Jump to content
Sign in to follow this  
dejhost

Slider

Recommended Posts

dejhost

Hi,

I am pretty new to Autoit and currently creating a GUI that contains some sliders. Very thankful for any hint!

1) Is it possible to label the ticks of a slider other than creating separate labels, that I position myself? Please see the code below - certainly there is a more elegant solution?

2) Lets say the slider shall range from 1 to 9, and I want only uneven numbers to be selectable. How do I do that?

 

This is how I solved it so far: I had to disable tooltips cause they contradict my lablels:

GUICtrlCreateLabel("Kernel", 25, 253)
    local $iKernel_size = GUICtrlCreateSlider (175, 250, 200,20)
    GUICtrlSetLimit ($iKernel_size,5,1)

    GUICtrlCreateLabel("1", 181, 273)
    GUICtrlCreateLabel("5", 271, 273)
    GUICtrlCreateLabel("9",361, 273)

... and did calculate afterwards the actual value:

$iKernel_size  = GUICtrlRead($iKernel_size)
$iKernel_size = ($iKernel_size * 2) -1

Thank you very much for helping!
 

Edited by dejhost

Share this post


Link to post
Share on other sites
Valuater

Maybe...

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
    ; Create a GUI with various controls.
    Local $hGUI = GUICreate("Example", 300, 200)

    ; Create a combobox control.
    Local $idComboBox = GUICtrlCreateCombo("Item 1", 10, 10, 185, 20)
    Local $idClose = GUICtrlCreateButton("Close", 210, 170, 85, 25)

    ; Add additional items to the combobox.
    GUICtrlSetData($idComboBox, "Item 3|Item 5|Item 7", "Item 1")

    ; Display the GUI.
    GUISetState(@SW_SHOW, $hGUI)

    Local $sComboRead = ""

    ; Loop until the user exits.
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE, $idClose
                ExitLoop

            Case $idComboBox
                $sComboRead = GUICtrlRead($idComboBox)
                MsgBox($MB_SYSTEMMODAL, "", "The combobox is currently displaying: " & $sComboRead, 0, $hGUI)

        EndSwitch
    WEnd

    ; Delete the previous GUI and all controls.
    GUIDelete($hGUI)
EndFunc   ;==>Example

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
dejhost

Hi Valuater,

Thanks for your post!

I appreciate the idea, but this is only one of many sliders I need. For most of them, a combobox is not applicable.

dejhost

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  

×