Sign in to follow this  
Followers 0
monji

updown control

5 posts in this topic

hi,

i'm trying to make my updown increment/decrement the value of the associated input control by 0.1. i have an idea on how to do this, but i need to find out which of the buttons was pressed. is there a way to know that?

Share this post


Link to post
Share on other sites



show us what you got so far

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

i have this, but it only works properly if you never edit the input manually. if you input a number, it will be multiplied by 0.1 when you press the updown. if you enter a decimal, the updown will ignore it and will continue from the last number (before you edited the input).

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("some form", 182, 114, 352, 335)
$Input1 = GUICtrlCreateInput("0", 25, 15, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Updown1 = GUICtrlCreateUpdown($Input1)
$Input2 = GUICtrlCreateInput("0", 25, 40, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Updown2 = GUICtrlCreateUpdown($Input2)
$Button1 = GUICtrlCreateButton("exit", 55, 75, 75, 25)
GUISetState(@SW_SHOW)

opt( 'GuiOnEventMode', 1 )
GUISetOnEvent( $GUI_EVENT_CLOSE, 'quit' )
GUICtrlSetOnEvent( $Updown1, 'onUpDown' )
GUICtrlSetOnEvent( $Updown2, 'onUpDown' )
GUICtrlSetOnEvent( $Button1, 'quit' )

While 1
    sleep(100)
WEnd

Func onUpDown()
    $val = GUICtrlRead( @GUI_CtrlId-1 )
    GUICtrlSetData( @GUI_CtrlId-1, StringFormat( '%.1f', $val * 0.1 ) )
EndFunc

Func quit()
    Exit
EndFunc

my idea is to copy the value of the input to a dummy, make the updown increment/decrement the value of the dummy, then the input value would be set to 0.1*(dummy value). so im asking if we can somehow detect which button was pressed. edit: that or just make the input value increase or decrease by 0.1 when pressed :o lol, i get needlessly long-winded sometimes

i hope there is an easy way to do this.

Edited by monji

Share this post


Link to post
Share on other sites

its easy to tell which button is presased

but the string formating the input... i cound'nt get it... dunno

#include <GUIConstants.au3>
; == GUI generated with Koda ==
$Form1 = GUICreate("some form", 182, 114, 352, 335)
$Input1 = GUICtrlCreateInput("0", 25, 15, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Updown1 = GUICtrlCreateUpdown($Input1)
$Input2 = GUICtrlCreateInput("0", 25, 40, 137, 21, -1, $WS_EX_CLIENTEDGE)
$Updown2 = GUICtrlCreateUpdown($Input2)
$Button1 = GUICtrlCreateButton("exit", 55, 75, 75, 25)
GUISetState(@SW_SHOW)

opt( 'GuiOnEventMode', 1 )
GUISetOnEvent( $GUI_EVENT_CLOSE, 'quit' )
GUICtrlSetOnEvent( $Updown1, 'onUpDown1' )
GUICtrlSetOnEvent( $Updown2, 'onUpDown2' )
GUICtrlSetOnEvent( $Button1, 'quit' )

While 1
    sleep(100)
WEnd

Func onUpDown()
    $val = GUICtrlRead( @GUI_CtrlId-1 )
    GUICtrlSetData( @GUI_CtrlId-1, StringFormat( '%.1f', $val * 0.1 ) )
EndFunc
; use the above or
Func onUpDown1()
    $val = StringFormat( '%.1f', (GUICtrlRead( $Input1 )) * 0.1)
;$val = StringFormat( '%.1f', $val * 0.1 )
    GUICtrlSetData( $Input1, $val )
EndFunc


Func onUpDown2()
    $val = GUICtrlRead( @GUI_CtrlId-1 )
    GUICtrlSetData( @GUI_CtrlId-1, StringFormat( '%.1f', $val * 0.1 ) )
EndFunc

Func quit()
    Exit
EndFunc

good luck

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

err, no i don't think that's it.

what i mean is which button in an updown control was pressed (up or down), not which updown control was pressed. there are 2 controls in the gui because i was testing some things a while back (something about putting the input control in and out of focus)

and the stringformat is there because i want to see '1.0' instead of '1' in the input control :o

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