Jump to content

Help with UpDown Ctrl


Recommended Posts

Hello All,

Im having troubles getting an UpDown Ctrl to function the way i want it to.  

Here is the code. 

$Gui = GUICreate ("",150,150)
$MaxLS = GUICtrlCreateInput ("410.0",40,10,70,-1,$ES_RIGHT)
$Level = GUICtrlCreateUpdown ($MaxLS)
GUICtrlSetLimit ($Level,510.0,200.0)

So I want the Input to initially read "410.0" and when i press the up or down arrow i would like the input to increase by "1.0"  (so clicking the up arrow 10 times would make the input read "420.0")

Right now when i click the up arrow, the input changes to "200" and then goes up by 1.

I think im missing something somewhere, or im just not getting how the up down works......

 

Any help is greatly appreciated.

 

Link to comment
Share on other sites

  • Moderators

JohnnyVolcom5,

It is the decimal point and place that is confusing the UpDown - it reads the initially set value as invalid and so starts at the set minimum value. As you want it to increase by a full unit each time, is the decimal display really necessary? :huh:

If it is required then we need to do a bit of trickery. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

JohnnyVolcom5,

It is the decimal point and place that is confusing the UpDown - it reads the initially set value as invalid and so starts at the set minimum value. As you want it to increase by a full unit each time, is the decimal display really necessary? :huh:

If it is required then we need to do a bit of trickery. ;)

M23

 

Hi M23,

It isnt required on this particular input box (would like to leave the decimal if its not too difficult) , but i will be creating two more input boxes with UpDowns that will be in the range of 0.10 - 0.90.   (those i would like to increase by 0.10)

Thanks for the quick response! 

Link to comment
Share on other sites

  • Moderators

JohnnyVolcom,

Then we need to do the trickery! :D

Give me a while to knock up an example for you - it is not an easy thing to do. ;)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

Sorry Melba for interfering :)

$Gui = GUICreate ("",150,150)
$MaxLS = GUICtrlCreateInput("",110,10,1,20)
$Level = GUICtrlCreateUpdown ($MaxLS)
GUICtrlSetLimit($Level,100,-210)
$display = GUICtrlCreateInput ("410.0",40,10,55,20)
GuiSetState()

while 1
$msg = GuiGetMsg()
If $msg = -3 Then Exit
If $msg = $Level Then GuiCtrlSetData($display, StringFormat("%.01f", GuiCtrlRead($MaxLS)+410))
wend
Link to comment
Share on other sites

  • Moderators

JohnnyVolcom,

Easier than I remembered: :D

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

$hGUI = GUICreate("Test", 500, 500)
GUISetBkColor(0xC4C4C4)

$cDummy_Input = GUICtrlCreateLabel("410.0 ", 40, 10, 50, 20, BitOr($SS_RIGHT, $SS_CENTERIMAGE))
GUICtrlSetBkColor($cDummy_Input, 0xFFFFFF)
$MaxLS = GUICtrlCreateInput("410", 90, 10, 20, 20)
$Level = GUICtrlCreateUpdown($MaxLS)
GUICtrlSetLimit($Level, 510, 200)

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 input
    If BitShift($wParam, 16) = $EN_CHANGE Then
        Switch BitAND($wParam, 0xFFFF)
            Case $MaxLS
                ; Set the label to the new total
                GUICtrlSetData($cDummy_Input, GUICtrlRead($MaxLS) & ".0 ")
        EndSwitch
    EndIf

EndFunc   ;==>_WM_COMMAND
I hope everything is clear, but please ask if not. :)

M23

Edit:

mikell,

Never a problem to offer a solution - and yours is much simpler. ;)

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

BTW ... :D

Gui = GUICreate ("",150,150)
$MaxLS = GUICtrlCreateInput("0",110,10,1,20)
$Level = GUICtrlCreateUpdown ($MaxLS)
GUICtrlSetLimit($Level,4,-4)
$display = GUICtrlCreateInput ("0.50",40,10,55,20)
GuiSetState()

while 1
$msg = GuiGetMsg()
If $msg = -3 Then Exit
If $msg = $Level Then GuiCtrlSetData($display, StringFormat("%.02f", GuiCtrlRead($MaxLS)/10+0.5))
wend
Edited by mikell
Link to comment
Share on other sites

 

Sorry Melba for interfering :)

$Gui = GUICreate ("",150,150)
$MaxLS = GUICtrlCreateInput("",110,10,1,20)
$Level = GUICtrlCreateUpdown ($MaxLS)
GUICtrlSetLimit($Level,100,-210)
$display = GUICtrlCreateInput ("410.0",40,10,55,20)
GuiSetState()

while 1
$msg = GuiGetMsg()
If $msg = -3 Then Exit
If $msg = $Level Then GuiCtrlSetData($display, StringFormat("%.01f", GuiCtrlRead($MaxLS)+410))
wend

 

Thanks Mikell!   This one is a little easier for me to understand.

 

JohnnyVolcom,

Easier than I remembered: :D

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

$hGUI = GUICreate("Test", 500, 500)
GUISetBkColor(0xC4C4C4)

$cDummy_Input = GUICtrlCreateLabel("410.0 ", 40, 10, 50, 20, BitOr($SS_RIGHT, $SS_CENTERIMAGE))
GUICtrlSetBkColor($cDummy_Input, 0xFFFFFF)
$MaxLS = GUICtrlCreateInput("410", 90, 10, 20, 20)
$Level = GUICtrlCreateUpdown($MaxLS)
GUICtrlSetLimit($Level, 510, 200)

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 input
    If BitShift($wParam, 16) = $EN_CHANGE Then
        Switch BitAND($wParam, 0xFFFF)
            Case $MaxLS
                ; Set the label to the new total
                GUICtrlSetData($cDummy_Input, GUICtrlRead($MaxLS) & ".0 ")
        EndSwitch
    EndIf

EndFunc   ;==>_WM_COMMAND
I hope everything is clear, but please ask if not. :)

M23

Edit:

mikell,

Never a problem to offer a solution - and yours is much simpler. ;)

 

 

Thanks again Melba!  I think most of it is pretty clear.  I will play around with both examples.  If i come across anymore problems i will report back.

Thanks Again Melba and Mikell!

 

Edit: Thanks for the help on the other input boxes Mikell!

Edited by JohnnyVolcom5
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...