Sign in to follow this  
Followers 0
lilx

guictrlread on input control change to integer value?

8 posts in this topic

hello,

i am working on a slider to work with a input control. now what i want is that the digit insert into input control the slider reacts to it. now i have come to the following problem. my slider has a limit from 25 to 255, now i wanted to add a check control in my source so when to value insert in the input is smaller then 25 or greater then 255 it brings the number back to the minimum or maximum

now because the returned value of guictrlread on a input is a string value I can't work with greater of less then. Can someone help with this problem? Or what is the best solution to this.

Thank you in advance,

lilx

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

int() ?

If Int($iSlider) >= 25 And Int($iSlider) <= 255 Then
Edited by Robjong

Share this post


Link to post
Share on other sites

int() ?

If Int($iSlider) >= 25 And Int($iSlider) <= 255 Then
thx for the response will look at it now :P

Share this post


Link to post
Share on other sites

i am not really having luck with it, i hope you guys can look at it a maybe a new pair of eyes can see the problem,

#Include <Constants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>

    Local $Slider, $button, $msg, $input, $trans = 255, $dummy, $dummy1
    
    GUICreate("Change Trans", 220, 115, 100, 200)
    
    $text1 = GUICtrlCreateLabel ( "Transparent", 1, 5, 60, 20 )
    $text2 = GUICtrlCreateLabel ( "Solid", 190, 5, 30, 20 )
    $Slider = GUICtrlCreateSlider(10, 20, 200, 30)
    GUICtrlSetLimit(-1, 255, 25) ; min/max value
    $text = GUICtrlCreateLabel ( "New transparency level", 25, 65, 135, 20 )
    $input = GUICtrlCreateInput($trans, 165, 60, 30, 20, $ES_NUMBER)
    $button = GUICtrlCreateButton("Apply new transparency", 45, 90, 125, 20)
    GUISetState()
    GUICtrlSetData($Slider, $trans)
    
    
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                Exit
            Case $msg = $button
                
                GUICtrlSetData ($Slider, $input)
                
                $trans = GUICtrlRead ( $Slider )
                MsgBox ( 48, "box", $trans )
            Case $msg = $Slider
                $dummy = GUICtrlRead ( $Slider )
                GUICtrlSetData ($input, $dummy)
                WinSetTrans ( "Change Trans", "", $dummy )
                
            Case $msg = $input
                $dummy1 = GUICtrlRead ($input)
                If Int($dummy1) > 255 Then
                    GUICtrlSetData ( $input, "255" )
                ElseIf Int($dummy1) < 25 Then
                    GUICtrlSetData ( $input, "25" )
                EndIf
                    MsgBox ( 48, "Dummy1", $dummy1 )    
                GUICtrlSetData ($Slider, Int($input))
                
        EndSelect       
    WEnd

it's not the cleanest code but it works so far only now having much trouble with combining the input with the slider.

Share this post


Link to post
Share on other sites

If $Input > 255 Then
    GUICtrlSetData ($Slider, "255")
    GUICtrlSetData ($Input, "255"
ElseIf $Input < 25 Then
    GUICtrlSetData ($Slider, "25")
    GUICtrlSetData ($Input, "25"
Else
    GUICtrlSetData ($Slider, $Input)
EndIf

Probably not the most efficient method, but it should work.

MDiesel

Share this post


Link to post
Share on other sites

i am not really having luck with it, i hope you guys can look at it a maybe a new pair of eyes can see the problem,

#Include <Constants.au3>
 #include <GUIConstantsEx.au3>
 #include <EditConstants.au3>
 
     Local $Slider, $button, $msg, $input, $trans = 255, $dummy, $dummy1
     
     GUICreate("Change Trans", 220, 115, 100, 200)
     
     $text1 = GUICtrlCreateLabel ( "Transparent", 1, 5, 60, 20 )
     $text2 = GUICtrlCreateLabel ( "Solid", 190, 5, 30, 20 )
     $Slider = GUICtrlCreateSlider(10, 20, 200, 30)
     GUICtrlSetLimit(-1, 255, 25); min/max value
     $text = GUICtrlCreateLabel ( "New transparency level", 25, 65, 135, 20 )
     $input = GUICtrlCreateInput($trans, 165, 60, 30, 20, $ES_NUMBER)
     $button = GUICtrlCreateButton("Apply new transparency", 45, 90, 125, 20)
     GUISetState()
     GUICtrlSetData($Slider, $trans)
     
     
     While 1
         $msg = GUIGetMsg()
         Select
             Case $msg = $GUI_EVENT_CLOSE
                 Exit
             Case $msg = $button
                 
                 GUICtrlSetData ($Slider, $input)
                 
                 $trans = GUICtrlRead ( $Slider )
                 MsgBox ( 48, "box", $trans )
             Case $msg = $Slider
                 $dummy = GUICtrlRead ( $Slider )
                 GUICtrlSetData ($input, $dummy)
                 WinSetTrans ( "Change Trans", "", $dummy )
                 
             Case $msg = $input
                 $dummy1 = GUICtrlRead ($input)
                 If Int($dummy1) > 255 Then
                     GUICtrlSetData ( $input, "255" )
                 ElseIf Int($dummy1) < 25 Then
                     GUICtrlSetData ( $input, "25" )
                 EndIf
                     MsgBox ( 48, "Dummy1", $dummy1 )   
                 GUICtrlSetData ($Slider, Int($input))
                 
         EndSelect      
     WEnd

it's not the cleanest code but it works so far only now having much trouble with combining the input with the slider.

Would probably work if you had this

GUICtrlSetData ($Slider, Int(GUICtrlRead($input)))

instead of

GUICtrlSetData ($Slider, Int($input))

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

Share this post


Link to post
Share on other sites

If $Input > 255 Then
    GUICtrlSetData ($Slider, "255")
    GUICtrlSetData ($Input, "255"
ElseIf $Input < 25 Then
    GUICtrlSetData ($Slider, "25")
    GUICtrlSetData ($Input, "25"
Else
    GUICtrlSetData ($Slider, $Input)
EndIf

Probably not the most efficient method, but it should work.

MDiesel

well the main problem is.. that input give a value as a string so you can't use > or < because it will always give a negative value, so this didn't work :P

Share this post


Link to post
Share on other sites

@ martin,

sorry didn't refresh window x ), but the probleem was indeed in what you said

GUICtrlSetData ($Slider, Int(GUICtrlRead($input)))
and got it working now :P

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