Jump to content
Sign in to follow this  
babaorom

decimal value in an GUICrtlCInput incremented with an UpDownCtrl

Recommended Posts

babaorom

Hi,

How is it possible to increment a decimal value inside an input Ctrl ?

for example : the InputCtrl contains 22.9 and after a click on the Up arrow the InputCtrl contains 23.0 ; 23.1 ; 23.2 .......

Thanks a lot for your help.

Share this post


Link to post
Share on other sites
Melba23

babaorom,

You cannot show a decimal value in the input directly - you have to cheat. :bye:

Here are 2 snippets taken from one of my scripts - the top one shows hh:mm in 5 min increments; the lower a decimal as you require:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <UpDownConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>

$hGUI = GUICreate("Test", 500, 500)

$cInput_Hour = GUICtrlCreateInput("0", 70, 37, 19, 20)
GUICtrlSetState(-1, $GUI_HIDE)
Local $cUpDown_Hour = GUICtrlCreateUpdown($cInput_Hour, BitOR($UDS_WRAP, $UDS_ALIGNLEFT))
GUICtrlSetLimit($cUpDown_Hour, 9, 0)
$cInput_Min = GUICtrlCreateInput("0", 125, 37, 19, 20)
GUICtrlSetState(-1, $GUI_HIDE)
Local $cUpDown_Min = GUICtrlCreateUpdown($cInput_Min, $UDS_WRAP)
GUICtrlSetLimit($cUpDown_Min, 11, 0)
$cHours_Label = GUICtrlCreateLabel("0:00", 90, 38, 30, 18, BitOR($SS_CENTER, $SS_CENTERIMAGE))

$cInput_Dec = GUICtrlCreateInput("0", 70, 137, 19, 20)
GUICtrlSetState(-1, $GUI_HIDE)
Local $cUpDown_Dec = GUICtrlCreateUpdown($cInput_Dec, BitOR($UDS_WRAP, $UDS_ALIGNLEFT))
$cDec_Label = GUICtrlCreateLabel("0.0", 90, 138, 30, 18, BitOR($SS_CENTER, $SS_CENTERIMAGE))

GUISetState()

GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND")

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func _WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)

    #forceref $hWnd, $iMsg, $lParam

    ; If it was an update message from the inputs
    If BitShift($wParam, 16) = $EN_CHANGE Then
        ; Check which it was
        Switch BitAND($wParam, 0xFFFF)
            Case $cInput_Hour, $cInput_Min
                ; Set the label to the new total
                GUICtrlSetData($cHours_Label, GUICtrlRead($cInput_Hour) & ":" & StringFormat("%02i", 5 * GUICtrlRead($cInput_Min)))
            Case $cInput_Dec
                ; Set the label to the formatted value
                GUICtrlSetData($cDec_Label, StringFormat("%.1f", GUICtrlRead($cInput_Dec) / 10))
        EndSwitch
    EndIf

EndFunc   ;==>_WM_COMMAND

Please ask if anything is unclear. :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
babaorom

Your answer is clear

I studied it, I did'nt known this possibility

Thanks :oops:

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  

×