Jump to content

limit input box 0-24


Gillboss
 Share

Recommended Posts

@Gillboss

Maybe try this.

$Hours = GUICtrlCreateInput("", 50, 67, 20, 20, $ES_NUMBER)
GUICtrlSetLimit($Hours,24,0)oÝ÷ Ú· j·l¦ÚÞÇú®¢×§¢Ü(®F®¶­sb4æ6ÇVFRfÇC´wVVFBæS2fwC°¢6æ6ÇVFRfÇC´uT6öç7FçG2æS2fwC° ¢b33c´ÖäuTÒuT7&VFRgV÷C´Æ&Òòb33´6Æö6²gV÷C²Â3Â# ¢b33c´÷W'2ÒuT7G&Ä7&VFTçWBgV÷C²gV÷C²ÂSÂcrÂ#Â#Âb33c´U5ôåTÔ$U"¤uT7G&Å6WDÆÖBb33c´÷W'2Ã#Bà ¤uT6WE7FFR  ¥vÆR¢b33c¶Ô×6rÒuTvWD×6r¢6VÆV7@¢66Rb33c¶Ô×6rÒb33c´uTôUdTåEô4Äõ4P¢W@¢VæE6VÆV7@¥tVæ
Link to comment
Share on other sites

GuiCtrlSetLimit

For Input/Edit controls it is the max number of characters that can be entered.

You can use something like this:

#Include <GuiEdit.au3>
#include <GUIConstants.au3>

$MainGUI = GUICreate("Alarm O'Clock", 300, 210)

$Hours = GUICtrlCreateInput("", 50, 67, 40, 20, $ES_NUMBER)
$limit = GUICtrlCreateUpdown($Hours)
GUICtrlSetLimit($limit,24,0)
GUISetState()


While 1
        $mMsg = GUIGetMsg()
        Select
            Case $mMsg = $GUI_EVENT_CLOSE
                Exit
        EndSelect
WEnd
Edited by Andreik

When the words fail... music speaks.

Link to comment
Share on other sites

i want limit GUICtrlCreateInput to numbers only and value of 0-24

i try it:

$Hours = GUICtrlCreateInput("", 50, 67, 20, 20, $ES_NUMBER)
GUICtrlSetLimit($Hours,0,24)

and its not work..

what fix?

#include <GuiConstantsEx.au3>
#include <editconstants.au3>
#include <windowsconstants.au3>
$MainGui = GUICreate('test', 300, 150)

$Input1 = GUICtrlCreateInput("", 50, 10, 150)
$ip1 = GUICtrlRead($Input1)


GUISetState()
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND");only used for EN_CHANGE so far

While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit

    EndSelect
WEnd



Func WM_COMMAND($hWnd, $imsg, $iwParam, $ilParam)
    Local $AtPos, $s1
    $nNotifyCode = BitShift($iwParam, 16)
    $nID = BitAND($iwParam, 0x0000FFFF)
    $hCtrl = $ilParam

    If $nNotifyCode = $EN_CHANGE Then
        If $ilParam = GUICtrlGetHandle($Input1) Then
            $s1 = GUICtrlRead($Input1)
            If $s1 = '-' Then $s1 = ''
            If $s1 > 24 Or $s1 < 0 Then
                GUICtrlSetData($Input1, $ip1)
            Else
                $ip1 = $s1
            EndIf

        EndIf

    EndIf

    Return $GUI_RUNDEFMSG


EndFunc ;==>WM_COMMAND
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

GuiCtrlSetLimit

For Input/Edit controls it is the max number of characters that can be entered.

You can use something like this:

#Include <GuiEdit.au3>
 #include <GUIConstants.au3>
 
 $MainGUI = GUICreate("Alarm O'Clock", 300, 210)
 
 $Hours = GUICtrlCreateInput("", 50, 67, 40, 20, $ES_NUMBER)
 $limit = GUICtrlCreateUpdown($Hours)
 GUICtrlSetLimit($limit,24,0)
 GUISetState()
 
 
 While 1
         $mMsg = GUIGetMsg()
         Select
             Case $mMsg = $GUI_EVENT_CLOSE
                 Exit
         EndSelect
 WEnd
thx, but user can insert himself number 56 for example, and its not good.
Link to comment
Share on other sites

#include <GuiConstantsEx.au3>
 #include <editconstants.au3>
 #include <windowsconstants.au3>
 $MainGui = GUICreate('test', 300, 150)
 
 $Input1 = GUICtrlCreateInput("", 50, 10, 150)
 $ip1 = GUICtrlRead($Input1)
 
 
 GUISetState()
 GUIRegisterMsg($WM_COMMAND, "WM_COMMAND");only used for EN_CHANGE so far
 
 While 1
     $msg = GUIGetMsg()
     Select
         Case $msg = $GUI_EVENT_CLOSE
             Exit
 
     EndSelect
 WEnd
 
 
 
 Func WM_COMMAND($hWnd, $imsg, $iwParam, $ilParam)
     Local $AtPos, $s1
     $nNotifyCode = BitShift($iwParam, 16)
     $nID = BitAND($iwParam, 0x0000FFFF)
     $hCtrl = $ilParam
 
     If $nNotifyCode = $EN_CHANGE Then
         If $ilParam = GUICtrlGetHandle($Input1) Then
             $s1 = GUICtrlRead($Input1)
             If $s1 = '-' Then $s1 = ''
             If $s1 > 24 Or $s1 < 0 Then
                 GUICtrlSetData($Input1, $ip1)
             Else
                 $ip1 = $s1
             EndIf
 
         EndIf
 
     EndIf
 
     Return $GUI_RUNDEFMSG
 
 
 EndFunc;==>WM_COMMAND
goooooooooooooooooooooood thx =]

cool.. just add $ES_NUMBER and its perfect =]

Link to comment
Share on other sites

thx, but user can insert himself number 56 for example, and its not good.

#Include <GuiEdit.au3>
#include <GUIConstants.au3>

$MainGUI = GUICreate("Alarm O'Clock", 300, 210)

$Hours = GUICtrlCreateInput("", 50, 67, 40, 20,BitOR($ES_NUMBER,$ES_READONLY))
$limit = GUICtrlCreateUpdown($Hours)
GUICtrlSetLimit($limit,24,0)
GUISetState()


While 1
        $mMsg = GUIGetMsg()
        Select
            Case $mMsg = $GUI_EVENT_CLOSE
                Exit
        EndSelect
WEnd

Now, I think is work fine.

When the words fail... music speaks.

Link to comment
Share on other sites

#Include <GuiEdit.au3>
 #include <GUIConstants.au3>
 
 $MainGUI = GUICreate("Alarm O'Clock", 300, 210)
 
 $Hours = GUICtrlCreateInput("", 50, 67, 40, 20,BitOR($ES_NUMBER,$ES_READONLY))
 $limit = GUICtrlCreateUpdown($Hours)
 GUICtrlSetLimit($limit,24,0)
 GUISetState()
 
 
 While 1
         $mMsg = GUIGetMsg()
         Select
             Case $mMsg = $GUI_EVENT_CLOSE
                 Exit
         EndSelect
 WEnd

Now, I think is work fine.

yes not its :) thx i think i use it =]
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...