Sign in to follow this  
Followers 0
CoolDomi

Updown Control

6 posts in this topic

Hi there,

I'm trying to change the updown control increment (instead increment/decrement by 1 make it by 5). Is there an easy way to get this to work? Also is there an event or something that I can check to determine if the up or down arrow of an updown control box has been activated?

thanks.

Dom.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

#include <GUIConstants.au3>
#include <GuiSlider.au3>

opt('MustDeclareVars', 1)

Dim $Gui_Slider, $slider1, $button, $msg, $h_slider, $Status, $hold_val

$Gui_Slider = GUICreate("Slider", 220, 100, 100, 200)
GUISetBkColor(0x00E0FFFF) ; will change background color

$slider1 = GUICtrlCreateSlider(10, 10, 200, 20)
GUICtrlSetLimit(-1, 200, 0); change min/max value
$button = GUICtrlCreateButton("Set Freq", 75, 55, 70, 20)
GUISetState()
GUICtrlSetData($slider1, 45); set cursor
$h_slider = ControlGetHandle($Gui_Slider, "", "msctls_trackbar321")
$Status = GUICtrlCreateLabel("Num of Tics: " & _GUICtrlSliderGetNumTics ($h_slider), 0, 80, 220, 20, BitOR($SS_SUNKEN, $SS_CENTER))
$hold_val = _GUICtrlSliderGetPos($h_slider)

While 1
    If $hold_val <> _GUICtrlSliderGetPos($h_slider) Then
        $hold_val = _GUICtrlSliderGetPos($h_slider)
        GUICtrlSetData($Status,"Pos: " & _GUICtrlSliderGetPos($h_slider))
    EndIf

   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         ExitLoop
      Case $msg = $button
         _GUICtrlSliderSetTicFreq ($h_slider, 5)
         GUICtrlSetData($Status, "Num of Tics: " & _GUICtrlSliderGetNumTics ($h_slider))
   EndSelect
WEnd

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Thanks gafrost, for the reply, I tried it but the slide scan still move one by one B) .

Anyhow I figure out an our solution with 2 separate buttons (up, down) and a readonly input cntrl. This give me the flexibily I'm looking for (know which button is pressed up or down, etc...).

Dom

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Thanks gafrost, for the reply, I tried it but the slide scan still move one by one B) .

Anyhow I figure out an our solution with 2 separate buttons (up, down) and a readonly input cntrl. This give me the flexibily I'm looking for (know which button is pressed up or down, etc...).

Dom

thinks your looking for _GUICtrlSliderSetPos($h_slider, $i_pos)

Edit: sorry been giving you infor for slider not updown control, what your wanting to do, probably would be easy, but i'm sure

someone could figure it out.

Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Think this is what your trying to do

#include "GUIConstants.au3"

$title = "My GUI UpDown"
GUICreate($title,-1,-1,-1,-1, $WS_SIZEBOX)

$input = GUICtrlCreateInput ("2",10,10, 50, 20, $ES_NUMBER)
$updown = GUICtrlCreateUpdown($input)
GUICtrlSetLimit($updown,100,0)
$old = 2
; Attempt to resize input control
GUICtrlSetPos($input, 10,10, 100, 40 )

GUISetState ()

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    If $old <> Int(GUICtrlRead($input)) Then
        If $old < Int(GUICtrlRead($input)) Then; up
            $old = ((Int(GUICtrlRead($input)) - $old) * 5) + $old
            If $old > 100 Then $old = 100
            GUICtrlSetData($input,$old)
        Else
            $old = (($old - Int(GUICtrlRead($input))) * -5) + $old
            If $old < 0 Then $old = 0
            GUICtrlSetData($input,$old)
        EndIf
    EndIf
            
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend

msgbox(0,"Updown",GUICtrlRead($input))
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Share this post


Link to post
Share on other sites

Once again thanks gafrost, this time it works great B)

Dom.

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