Jump to content

Help with control limits


telmob
 Share

Recommended Posts

I have some controls i need to limit in size and to restrict to text or numbers, but i have no idea how to do this.

I know that GUICtrlSetLimit is a valid option to limit size in my GUI's input and edit box, but how can i do that in combos?

I'm trying to restrict my first input to text, my second to numbers, limit the size of my combo boxes and restrict the first to text and the second to numbers, and finally limit the line size in my edit box, not the whole text but only the line size or simply to enter a @CRLF automatically at the end of each line limit.

I know this is to much to ask, but i've searched everywhere and the only help i found here on the forum was from 2006 and no longer works. :S

Help please?!

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 236, 280, 655, 370)
$Input1 = GUICtrlCreateInput("Input1", 16, 16, 121, 21)
$Combo1 = GUICtrlCreateCombo("Combo1", 16, 80, 121, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Button1 = GUICtrlCreateButton("Button1", 144, 16, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 144, 48, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 16, 144, 201, 89, , $ES_AUTOVSCROLL + $WS_VSCROLL)
GUICtrlSetData(-1, "EDIT1")
$Button3 = GUICtrlCreateButton("Button3", 144, 240, 75, 25)
$Input2 = GUICtrlCreateInput("Input2", 16, 48, 121, 21)
$Combo2 = GUICtrlCreateCombo("Combo2", 16, 112, 121, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Button4 = GUICtrlCreateButton("Button4", 144, 80, 75, 57)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd
Link to comment
Share on other sites

I have some controls i need to limit in size and to restrict to text or numbers, but i have no idea how to do this.

I know that GUICtrlSetLimit is a valid option to limit size in my GUI's input and edit box, but how can i do that in combos?

I'm trying to restrict my first input to text, my second to numbers, limit the size of my combo boxes and restrict the first to text and the second to numbers, and finally limit the line size in my edit box, not the whole text but only the line size or simply to enter a @CRLF automatically at the end of each line limit.

I know this is to much to ask, but i've searched everywhere and the only help i found here on the forum was from 2006 and no longer works. :S

Help please?!

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form2 = GUICreate("Form2", 236, 280, 655, 370)
$Input1 = GUICtrlCreateInput("Input1", 16, 16, 121, 21)
$Combo1 = GUICtrlCreateCombo("Combo1", 16, 80, 121, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Button1 = GUICtrlCreateButton("Button1", 144, 16, 75, 25)
$Button2 = GUICtrlCreateButton("Button2", 144, 48, 75, 25)
$Edit1 = GUICtrlCreateEdit("", 16, 144, 201, 89, , $ES_AUTOVSCROLL + $WS_VSCROLL)
GUICtrlSetData(-1, "EDIT1")
$Button3 = GUICtrlCreateButton("Button3", 144, 240, 75, 25)
$Input2 = GUICtrlCreateInput("Input2", 16, 48, 121, 21)
$Combo2 = GUICtrlCreateCombo("Combo2", 16, 112, 121, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
$Button4 = GUICtrlCreateButton("Button4", 144, 80, 75, 57)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

Try searching for CBN_EDITUPDATE or CBN_EDITCHANGE
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

I thank you for your help, but i have no idea what that's for or how to use it with autoit... :)

Please keep in mind i'm a complete Noob.

Could you please post a small example?

Edit: OK, i've been searching the forum for this and i'll try it to see what i can do.

Edited by telmob
Link to comment
Share on other sites

I'm going to need some help. I've found how to limit the combo, but that's about it.

Can i use CBN_EDITUPDATE and CBN_EDITCHANGE to limit each line entry in edit boxes?

You need $EN_CHANGE.

$CBN_* are notifications for a combobox. For Edit notifications you need $EN_* in general.

You can find all this here.

Here is a small example to limit the number typed into an edit to no more than 1234. (Could be an input, same thing.)

; *** Start added by AutoIt3Wrapper ***
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
; *** End added by AutoIt3Wrapper ***
#AutoIt3Wrapper_Add_Constants=n
Global $ILastED1Val = 0, $iMaxEd1 = 1234

$hG = GUICreate("Example for EN_CHANGE")
$ed1 = GUICtrlCreateEdit("", 10, 10, 200, 100)
GUIRegisterMsg($WM_COMMAND, "My_WM_COMMAND");only used for EN_CHANGE so far
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then Exit

WEnd



Func My_WM_COMMAND($hWnd, $imsg, $iwParam, $ilParam)
    Local $iNew, $sText
    $nNotifyCode = BitShift($iwParam, 16)
    $nID = BitAND($iwParam, 0x0000FFFF)
    $hCtrl = $ilParam

    If $nNotifyCode = $EN_CHANGE Then
        If $ilParam = GUICtrlGetHandle($ed1) Then

            $sText = GUICtrlRead($ed1)
            $iNew = Number($stext)
            if Stringlen(string($iNew)) <> stringlen($stext) then GUICtrlSetData($ed1, $iNew)
            If $iNew > $iMaxEd1 Then
                $iNew = $ILastED1Val
                GUICtrlSetData($ed1, $iNew)
                ConsoleWrite("stage1" & @CRLF)
            elseif $iNew <> $ILastED1Val then
                GUICtrlSetData($ed1, $iNew)
                $ILastED1Val = $iNew
                ConsoleWrite("stage 2" & @CRLF)
            EndIf

        EndIf

    EndIf

    Return $GUI_RUNDEFMSG


EndFunc   ;==>My_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

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...