Jump to content

Recommended Posts

Posted

Hello
Dear Sirs, I have a question please
About UPDown ctrl
Where I want to adjust its format
For example, I want to create a window to set the clock like the window in the system
Can this be done?
here's the example
______

#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <UpDownConstants.au3>
goto()
func Goto()
local $wGoto = GUICreate("go to spissific position", 250, 180, @DesktopWidth / 2 - 192, @DesktopHeight / 2 - 235, -1)
GUICtrlCreateLabel("please write a corect position to go to it", 50, 10, 220, 20)
GUICtrlCreateLabel("hours", 0, 80, 100, 30)
local $Inp1 = GUICtrlCreateInput("00", 0, 90, 100, 20, $ES_NUMBER + $WS_TABSTOP)
    GUICtrlCreateUpdown($Inp1, $UDS_ARROWKEYS)
GUICtrlSetLimit(-1, 23, 0)
GUICtrlCreateLabel("minuts", 110, 80, 100, 30)
local $Inp2 = GUICtrlCreateInput("00", 110, 90, 100, 20, $ES_NUMBER + $WS_TABSTOP)
    GUICtrlCreateUpdown($Inp2, $UDS_ARROWKEYS)
GUICtrlSetLimit(-1, 60, 0)
GUICtrlCreateLabel("seconds", 220, 80, 100, 30)
local $Inp3 = GUICtrlCreateInput("00", 220, 90, 100, 20, $ES_NUMBER + $WS_TABSTOP)
    GUICtrlCreateUpdown($Inp3, $UDS_ARROWKEYS)
GUICtrlSetLimit(-1, 60, 0)
local $Ok = GUICtrlCreateButton("&ok", 0, 150, 50, 30, 0x01)
local $cancel = GUICtrlCreateButton("&cancel", 200, 150, 50, 30)
GUISetState(@sw_show, $WgoTo)
while 1
switch GUIGetMSG()
case $GUI_Event_Close, $cancel
exit
case $OK
local $read1 = GUICtrlRead($inp1)
if $read1 >= 1 then $Read1 = ($Read1*60)*60
local $read2 = GUICtrlRead($inp2)
if $read2 >= 1 then $Read2 = $Read2*60
local $read3 = GUICtrlRead($inp3)
GUIDelete($WgoTo)
Return $read1+$read2+$read3
exit
endSwitch
Wend
EndFunc


________
What I need is to be the contents of the inputs as follows when i change the value of the UPDown CTRL
00
01
02
03
...

 

Posted

This will do it, adding a leading zero to the number in the input control.

While 1
        Switch GUIGetMsg()
            Case $GUI_Event_Close, $cancel
                Exit
            Case $Ok
                Local $read1 = GUICtrlRead($Inp1)
                If $read1 >= 1 Then $read1 = ($read1 * 60) * 60
                Local $read2 = GUICtrlRead($Inp2)
                If $read2 >= 1 Then $read2 = $read2 * 60
                Local $read3 = GUICtrlRead($Inp3)
                GUIDelete($wGoto)
                Return $read1 + $read2 + $read3
                Exit
            Case $Inp1 ; <<<<<<<<<<<<<<<<<<<<<<
                $Temp = GUICtrlRead($Inp1) ; <<<<<<<<<<<<<<<<<<<<<<
                GUICtrlSetData($Inp1, StringFormat("%02i", $Temp)) ; <<<<<<<<<<<<<<<<<<<<<<
        EndSwitch
    WEnd

The last three lines will modify the number in $Inp1 when you change it, and it's 9 or under.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Posted

Hello again.
@BrewManNH
I did  what i wanted
Thanks dear, for your help.
here's the code that i used

#include <WindowsConstants.au3>
#include <GuiEdit.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <UpDownConstants.au3>
goto()
func Goto()
local $wGoto = GUICreate("go to spissific position", 350, 180)
GUICtrlCreateLabel("please write a corect position to go to it", 50, 10, 220, 20)
GUICtrlCreateLabel("hours", 5, 80, 100, 30)
local $Inp1 = GUICtrlCreateInput("00", 5, 110, 100, 20, $ES_NUMBER + $WS_TABSTOP)
    GUICtrlCreateUpdown($Inp1, $UDS_ARROWKEYS)
GUICtrlSetLimit(-1, 23, 0)
GUICtrlCreateLabel("minuts", 110, 80, 100, 30)
local $Inp2 = GUICtrlCreateInput("00", 110, 110, 100, 20, $ES_NUMBER + $WS_TABSTOP)
    GUICtrlCreateUpdown($Inp2, $UDS_ARROWKEYS)
GUICtrlSetLimit(-1, 60, 0)
GUICtrlCreateLabel("seconds", 220, 80, 100, 30)
local $Inp3 = GUICtrlCreateInput("00", 220, 110, 100, 20, $ES_NUMBER + $WS_TABSTOP)
    GUICtrlCreateUpdown($Inp3, $UDS_ARROWKEYS)
GUICtrlSetLimit(-1, 60, 0)
local $Ok = GUICtrlCreateButton("&ok", 10, 150, 50, 30, 0x01)
local $cancel = GUICtrlCreateButton("&cancel", 200, 150, 50, 30)
GUISetState(@sw_show, $WgoTo)
local $s_MSG
while 1
$s_MSG = GUIGetMSG()
switch $s_MSG
case $GUI_Event_Close, $cancel
exit
    case $OK
local $read1 = GUICtrlRead($inp1)
if $read1 >= 1 then $Read1 = ($Read1*60)*60
local $read2 = GUICtrlRead($inp2)
if $read2 >= 1 then $Read2 = $Read2*60
local $read3 = GUICtrlRead($inp3)
GUIDelete($WgoTo)
Return $read1+$read2+$read3
    Case $Inp1, $inp2, $inp3
$Temp = GUICtrlRead($s_MSG)
GUICtrlSetData($s_MSG, StringFormat("%02i", $Temp))
    _GUICtrlEdit_SetSel($s_MSG, 0, -1)
    endSwitch
Wend
endFunc

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
×
×
  • Create New...