Jump to content

GUICtrlCreateUpdown


Bert
 Share

Recommended Posts

I made a simple input box:

$Wgroup4 = GUICtrlCreateGroup("Reboot",215, 156, 225,75)
            $inireboot1 = iniread("config\config.ini", "Config", "RebootTimer", "15")
            $Wreboot1 =  GUICtrlCreateinput("", 220, 180, 35, 20, 0x2000)
            GUICtrlSetData($Wreboot1,$inireboot1,15)
            GUICtrlSetTip(-1, "This is the amount of seconds" & @CRLF &"before the system will reboot"& @CRLF &"after all applications are processed.")
            $Wreboot2 =  GUICtrlCreateUpdown($Wreboot1)
            GUICtrlSetLimit($Wreboot1, 2, 1)
            GUICtrlCreatelabel("Reboot Timeout",259, 183)

My question is this: I want to limit the range of the up - down scrolling from 1 to 99. If the scroll reaches 99 or 1, it stops unless you start scrolling the other way. I will allow the user to type something in, but I want the same range limit imposed. Any thoughts?

Edited by vollyman
Link to comment
Share on other sites

I know I can use GUICtrlSetLimit to to limit the max number of characters that can be entered. I can limit it to 2. The problem is When scrolling down, I can get into negative numbers. This is something I like to avoid.

Edited by vollyman
Link to comment
Share on other sites

  • Moderators

anyone at all??????? please? :lmao:

Anyone at all... or someone with an answer that will work for you? ;) ... I haven't used the commands your talking about, so I'm the 'Anyone at all', just not the 'Anyone with the answer' o:)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

its easier for us if you create the example

like this

#include <GuiConstants.au3>


GUICreate("Test GUI")


$Wgroup4 = GUICtrlCreateGroup("Reboot", 215, 156, 225, 75)
$inireboot1 = IniRead("config\config.ini", "Config", "RebootTimer", "15")
$Wreboot1 = GUICtrlCreateInput("", 220, 180, 35, 20, 0x2000)
GUICtrlSetData($Wreboot1, $inireboot1, 15)
GUICtrlSetTip(-1, "This is the amount of seconds" & @CRLF & "before the system will reboot" & @CRLF & "after all applications are processed.")
$Wreboot2 = GUICtrlCreateUpdown($Wreboot1)
GUICtrlSetLimit($Wreboot1, 2, 1)
GUICtrlSetLimit($Wreboot2, 99, 1)
GUICtrlCreateLabel("Reboot Timeout", 259, 183)

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then Exit
    
WEnd

this has your answer also

8)

NEWHeader1.png

Link to comment
Share on other sites

$dmg_armorlabel=GUICtrlCreateLabel("Armor:", 38,142,32,18)
$dmg_armorbutton=GuiCtrlCreateInput("0",70,140,48,20,BitOr(20,$ES_NUMBER),0x2001)
$dmg_armorscroll=GuiCtrlCreateUpDown($dmg_armorbutton)
GUICtrlSetLimit($dmg_armorscroll,100,-10)

Thats what Im using in my program, I have a problem too, though. For some reason when you scroll into negatives instead of saying "-10", "-5" it says "5-" and "10-" :lmao:

How do you fix that?

Link to comment
Share on other sites

i just tried it and it worked for me

#include <GuiConstants.au3>


GUICreate("Test GUI")


$dmg_armorlabel=GUICtrlCreateLabel("Armor:", 38,142,32,18)
$dmg_armorbutton=GuiCtrlCreateInput("0",70,140,48,20,BitOr(20,$ES_NUMBER),0x2001)
$dmg_armorscroll=GuiCtrlCreateUpDown($dmg_armorbutton)
GUICtrlSetLimit($dmg_armorscroll,100,-10)

GUISetState()

While 1
    $msg = GUIGetMsg()
    
    If $msg = $GUI_EVENT_CLOSE Then Exit
    
WEnd

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Moderators

I changed the GUICtrlSetLimit($dmg_armorscroll,100,-10) to GUICtrlSetLimit($dmg_armorscroll,100,1) and it did exactly as vollyman asked... went from 1 to 100 or 100 to 1 nothing above or below... Nice job Val!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Ok, I see what you did. I had the GUICtrlSetLimit tied to GuiCtrlCreateInput, not GuiCtrlCreateUpDown. The function reference wasn't very clear, and that is why I was having trouble. In what is listed as related it gives GuiCtrlCreateList, GuiCtrlCreateInput, and GuiCtrlCreateEdit. It should say GuiCtrlCreateUpDown as one of the choices.

Thanks Val for the fix.

@ Smoke: I dub you "anyone at all" heheh

Edited by vollyman
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...