monji Posted February 20, 2006 Share Posted February 20, 2006 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? Link to comment Share on other sites More sharing options...
Valuater Posted February 20, 2006 Share Posted February 20, 2006 show us what you got so far 8) Link to comment Share on other sites More sharing options...
monji Posted February 20, 2006 Author Share Posted February 20, 2006 (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 lol, i get needlessly long-winded sometimes i hope there is an easy way to do this. Edited February 20, 2006 by monji Link to comment Share on other sites More sharing options...
Valuater Posted February 20, 2006 Share Posted February 20, 2006 its easy to tell which button is presased but the string formating the input... i cound'nt get it... dunno expandcollapse popup#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) Link to comment Share on other sites More sharing options...
monji Posted February 20, 2006 Author Share Posted February 20, 2006 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 Link to comment Share on other sites More sharing options...
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