Jump to content

Return to 0 on slider when checkbox is off


retaly
 Share

Recommended Posts

hy guys, almost ready this part of my full scrip,

only one small thing what still i couldnt fixing...

my problem is: should to Return to 0 on slider when checkbox is off, and slider change to $GUI_DISABLE, $GUI_UNCHECKED as i wrote below in script.

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Global $Slider_hold

Local $slider1, $msg, $lightvalue, $state, $lightslider, $lightlabel, $STATE1

GUICreate("slider", 500, 400)
$STATE1 = 0;"UNCHECKED"
$lightslider = GUICtrlCreateCheckbox("", 10, 17, 14, 20)
$lightlabel = GUICtrlCreateLabel("Light:", 25, 20, 50, 20)
$slider1 = GUICtrlCreateSlider(120, 20, 200, 20)
GUICtrlSetState(-1, BitOr($GUI_DISABLE, $GUI_UNCHECKED))
GUICtrlSetLimit(-1, 99, 0) ; change min/max value
$lightvalue = GUICtrlCreateLabel($state, 65, 20, 13, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()




While 1
Switch GUIGetMsg()
Case $lightslider
_lightChange()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

Func _lightChange()
$State1 = NOT $State1
If $State1 Then
GUICtrlSetState($slider1, BitOr($GUI_ENABLE, $GUI_CHECKED))
slider_opt()
Else
GUICtrlSetState($slider1, BitOr($GUI_DISABLE, $GUI_UNCHECKED))
GUICtrlSetData($lightvalue, "0")
EndIf
EndFunc


Func slider_opt()
Do
$state = GUICtrlRead($slider1)
If $state <> $Slider_hold Then
GUICtrlSetData($lightvalue, $state)
$Slider_hold = $state
EndIf
$msg = GUIGetMsg()
Until $msg = $GUI_EVENT_CLOSE
EndFunc
Edited by retaly
Link to comment
Share on other sites

Hi,

You have to keep only one While in your script to be able to receive GUI messages from your main while, plus I don't know why you are using the GUI_CHECKED and GUI_UNCHECKED states for the slider...

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Global $Slider_hold

Local $slider1, $msg, $lightvalue, $state, $lightslider, $lightlabel, $STATE1

GUICreate("slider", 500, 400)
$STATE1 = 0;"UNCHECKED"
$lightslider = GUICtrlCreateCheckbox("0", 10, 17, 14, 20)
$lightlabel = GUICtrlCreateLabel("Light:", 25, 20, 50, 20)
$slider1 = GUICtrlCreateSlider(120, 20, 200, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetLimit(-1, 99, 0) ; change min/max value
$lightvalue = GUICtrlCreateLabel($state, 65, 20, 13, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()

While 1
Switch GUIGetMsg()
Case $lightslider
_lightChange()
Case $slider1
GUICtrlSetData($lightvalue, GUICtrlRead($slider1))
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd

Func _lightChange()
$STATE1 = Not $STATE1
If $STATE1 Then
GUICtrlSetState($slider1, $GUI_ENABLE)
Else
GUICtrlSetState($slider1, $GUI_DISABLE)
GUICtrlSetData($slider1, 0)
GUICtrlSetData($lightvalue, "0")
EndIf
EndFunc   ;==>_lightChange

Br, FireFox.

Link to comment
Share on other sites

using GUI_CHECKED and GUI_UNCHECKED for checkbox,

You were using it for the slider.

tested and now slider doesnt working with 3rd mouse button, its important to me, :(

What do you want it to do? I don't have a mouse on my computer right now.

Br, FireFox.

Link to comment
Share on other sites

i mean, need there the slider_op() to working 3rd mouse, but in this situation i went one step to forward, and two step to back..

because 3rd mouse button again working, but doesnt return to 0 and gui_disable to slider...

:// i have to find the best way to use both option in one option what works...

try out the two different script then you will understand it if still dont.

Edited by retaly
Link to comment
Share on other sites

You can not trap the slider scroll event in autoit (or nobody has given the solution) so you have to check for its value like you did :

#include <GUIConstantsEx.au3>

Opt('MustDeclareVars', 1)

Local $slider1, $lightvalue, $lightslider, $lightlabel, $STATE1 = False

Local $iSliderValue = -1, $iLastSliderValue = 0

GUICreate("slider", 500, 400)
$lightslider = GUICtrlCreateCheckbox("0", 10, 17, 14, 20)
$lightlabel = GUICtrlCreateLabel("Light:", 25, 20, 50, 20)
$slider1 = GUICtrlCreateSlider(120, 20, 200, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetLimit(-1, 99, 0) ; change min/max value
$lightvalue = GUICtrlCreateLabel("0", 65, 20, 13, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()

While 1
Switch GUIGetMsg()
Case $lightslider
_lightChange()
Case $GUI_EVENT_CLOSE
Exit
EndSwitch

If $STATE1 Then
$iSliderValue = GUICtrlRead($slider1)

If $iSliderValue <> $iLastSliderValue Then
GUICtrlSetData($lightvalue, $iSliderValue)

$iLastSliderValue = $iSliderValue
EndIf
EndIf
WEnd

Func _lightChange()
$STATE1 = Not $STATE1
If $STATE1 Then
GUICtrlSetState($slider1, $GUI_ENABLE)
Else
GUICtrlSetState($slider1, $GUI_DISABLE)
GUICtrlSetData($slider1, 0)
GUICtrlSetData($lightvalue, "0")
EndIf
EndFunc   ;==>_lightChange

Br, FireFox.

Link to comment
Share on other sites

  • Moderators

FireFox,

You can not trap the slider scroll event in autoit

Oh yes you can: ;)

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

Opt('MustDeclareVars', 1)

Local $slider1, $lightvalue, $lightslider, $lightlabel, $STATE1 = False

Local $iSliderValue = -1, $iLastSliderValue = 0

GUICreate("slider", 500, 400)
$lightslider = GUICtrlCreateCheckbox("0", 10, 17, 14, 20)
$lightlabel = GUICtrlCreateLabel("Light:", 25, 20, 50, 20)
$slider1 = GUICtrlCreateSlider(120, 20, 200, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
GUICtrlSetLimit(-1, 99, 0) ; change min/max value
$lightvalue = GUICtrlCreateLabel("0", 65, 20, 13, 20)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()

GUIRegisterMsg($WM_HSCROLL, "_WM_HSCROLL") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

While 1
    Switch GUIGetMsg()
        Case $lightslider
            _lightChange()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _lightChange()
    $STATE1 = Not $STATE1
    If $STATE1 Then
        GUICtrlSetState($slider1, $GUI_ENABLE)
    Else
        GUICtrlSetState($slider1, $GUI_DISABLE)
        GUICtrlSetData($slider1, 0)
        GUICtrlSetData($lightvalue, "0")
    EndIf
EndFunc   ;==>_lightChange

; React to slider movement
Func _WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    #forceref $hWnd, $iMsg
    If $lParam = GUICtrlGetHandle($slider1) Then
        If BitAND($wParam, 0xFFFF) = 5 Then ; LoWord = $SB_THUMBTRACK
            GUICtrlSetData($lightvalue, GUICtrlRead($slider1))
        EndIf
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_HSCROLL

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

@M23

You forgot to add "or nobody has given the solution" in your quote :idiot:

Do you remember the PM I sent you about my scrollbars problem, at least the event problem ?

So, the event is not working for me... f*cking computers.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...