Cyberwing Posted September 22, 2020 Posted September 22, 2020 Hi all, I have a slider that I would like to set a limit that the cursor/selector can reach but can't go higher on the slider bar. As exemple: the slider is 0 to 100, but I want the selector to stop at 75 so at the 3/4 of the bar. I tried the set range and set limit, but that change the end value of the bar. Thanks in adavanced! $cargocalculatorcargoselectorslider = GUICtrlCreateSlider(100, 170, 550, 30) GUICtrlSetLimit($cargocalculatorcargoselectorslider, 100, 0)
zeenmakr Posted September 22, 2020 Posted September 22, 2020 like this expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("slider", 220, 100, 100, 200) GUISetBkColor(0x00E0FFFF) ; will change background color Local $iSliderInit = 50 ;slider initial position Local $iSliderMaxPercent = 75 ;limit slider position Local $idSlider1 = GUICtrlCreateSlider(10, 10, 200, 20) GUICtrlSetLimit(-1, 100, 0) ; change min/max value GUICtrlSetData($idSlider1, $iSliderInit) ; set cursor Local $idButton = GUICtrlCreateButton("Value?", 75, 70, 70, 20) Local $idLabel = GUICtrlCreateLabel($iSliderInit, 105, 35, 30, 20) GUISetState(@SW_SHOW) $iSliderInit = GUICtrlRead($idSlider1) While 1 $iSliderCurrent = GUICtrlRead($idSlider1) If $iSliderCurrent <> $iSliderInit then GUICtrlSetData($idLabel, $iSliderCurrent) $iSliderInit = $iSliderCurrent EndIf Local $idMsg = GUIGetMsg() Switch $idMsg Case $GUI_EVENT_CLOSE Exit Case $idButton MsgBox($MB_SYSTEMMODAL, "slider1", GUICtrlRead($idSlider1), 2) Case $idSlider1 Local $idSliderPos = GUICtrlRead($idSlider1) If $idSliderPos >= $iSliderMaxPercent Then Local $iSliderCustom = InputBox('WARNING! Exceeded '&$iSliderMaxPercent&'%', _ 'Set Max '&$iSliderMaxPercent&'% or Enter new Value', $iSliderMaxPercent) GUICtrlSetData($idSlider1, $iSliderCustom) ; set cursor EndIf EndSwitch WEnd Exit EndFunc ;==>Example
Cyberwing Posted September 23, 2020 Author Posted September 23, 2020 On 9/22/2020 at 1:29 PM, zeenmakr said: like this expandcollapse popup#include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> Example() Func Example() GUICreate("slider", 220, 100, 100, 200) GUISetBkColor(0x00E0FFFF) ; will change background color Local $iSliderInit = 50 ;slider initial position Local $iSliderMaxPercent = 75 ;limit slider position Local $idSlider1 = GUICtrlCreateSlider(10, 10, 200, 20) GUICtrlSetLimit(-1, 100, 0) ; change min/max value GUICtrlSetData($idSlider1, $iSliderInit) ; set cursor Local $idButton = GUICtrlCreateButton("Value?", 75, 70, 70, 20) Local $idLabel = GUICtrlCreateLabel($iSliderInit, 105, 35, 30, 20) GUISetState(@SW_SHOW) $iSliderInit = GUICtrlRead($idSlider1) While 1 $iSliderCurrent = GUICtrlRead($idSlider1) If $iSliderCurrent <> $iSliderInit then GUICtrlSetData($idLabel, $iSliderCurrent) $iSliderInit = $iSliderCurrent EndIf Local $idMsg = GUIGetMsg() Switch $idMsg Case $GUI_EVENT_CLOSE Exit Case $idButton MsgBox($MB_SYSTEMMODAL, "slider1", GUICtrlRead($idSlider1), 2) Case $idSlider1 Local $idSliderPos = GUICtrlRead($idSlider1) If $idSliderPos >= $iSliderMaxPercent Then Local $iSliderCustom = InputBox('WARNING! Exceeded '&$iSliderMaxPercent&'%', _ 'Set Max '&$iSliderMaxPercent&'% or Enter new Value', $iSliderMaxPercent) GUICtrlSetData($idSlider1, $iSliderCustom) ; set cursor EndIf EndSwitch WEnd Exit EndFunc ;==>Example Thanks a lot! Working like a charm!
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