Merchants 0 Posted November 2, 2010 (edited) how to set a limit? like $GUI = GuiCtrlCreateInput("10 chars max!", 213, 45, 32, 20) GUICtrlSetLimit($GUI, 10) but then in a combo box $GUI = GUICtrlCreateCombo("10 chars max!", 141, 22, 104, 20) GUICtrlSetLimit($GUI, 10) ?? Edited November 2, 2010 by Merchants Share this post Link to post Share on other sites
GEOSoft 68 Posted November 2, 2010 GUICtrlSetLimit() Can be used for Up/Down, slider, edit, input and list controls but I don't think it has any effect on a combobox. GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!" Share this post Link to post Share on other sites
PsaltyDS 41 Posted November 2, 2010 A ComboBox only presents choices presented by the application in the control, so limits don't make sense there. But you can have an Edit control (input) subclassed on to the ComboBox and maybe you could apply it to that. I haven't tried it, but you might get the handle to the edit with _GUICtrlComboBoxEx_GetEditControl() and set a limit on that. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Share this post Link to post Share on other sites
BrewManNH 1,306 Posted November 2, 2010 The contents of a combo box are set by the programmer, don't use more characters than you want displayed in your combo box and you won't need to try and set a limit. A user can type in a combo box, but if you only check for the contents that you put into it, then that shouldn't be an issue. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way!I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Share this post Link to post Share on other sites
Melba23 3,489 Posted November 2, 2010 Merchants,Here is one way to do it: #include <GUIConstantsEx.au3> #Include <GuiComboBox.au3> $hGUI = GUICreate("Test", 500, 500) $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) GUICtrlSetData($hCombo, "Option1|Option2") $hComboDummy = GUICtrlCreateDummy() GUISetState() Global $AccelKeys[1][2]=[["{ENTER}", $hComboDummy]] GUISetAccelerators($AccelKeys) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $hComboDummy ContinueCase Case $hCombo ConsoleWrite(GUICtrlRead($hCombo) & @CRLF) EndSwitch $sText = GUICtrlRead($hCombo) If StringLen($sText) > 10 Then $sText = StringMid($sText, 1, 10) _GUICtrlComboBox_SetEditText($hCombo, $sText) EndIf WEndThere are probably sexier ways to do it by getting the handle of the edit control and and looking for $EN_CHANGE messages, but this works for me! M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Share this post Link to post Share on other sites
PsaltyDS 41 Posted November 3, 2010 This was what I meant, and you don't have to monitor it at all: #include <GuiConstantsEx.au3> #include <GuiEdit.au3> #include <GuiComboBoxEx.au3> Global $hGUI, $hCombo, $hEdit ; Create GUI $hGUI = GUICreate("ComboBoxEx Get Edit Control", 400, 300) $hCombo = _GUICtrlComboBoxEx_Create($hGUI, "", 2, 2, 394, 268) For $x = 0 To 5 _GUICtrlComboBoxEx_AddString($hCombo, StringFormat("%03d : Random string", Random(1, 100, 1))) Next $hEdit = _GUICtrlComboBoxEx_GetEditControl($hCombo) _GUICtrlEdit_SetLimitText($hEdit, 16) GUISetState() ; Loop until user exits MsgBox(64, "Limit", "ComboBox Edit control limit = " & _GUICtrlEdit_GetLimitText($hEdit)) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Share this post Link to post Share on other sites
Melba23 3,489 Posted November 3, 2010 Just for completeness, here is a way to limit the number of characters using the Windows message as I mentioned above: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GuiComboBox.au3> $hGUI = GUICreate("Test", 500, 500) $hCombo = GUICtrlCreateCombo("", 10, 10, 200, 20) $hCombo_Handle = GUICtrlGetHandle($hCombo) GUICtrlSetData($hCombo, "Option 1|Option 2") 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 Local $hWndFrom = $lParam Local $iCode = BitShift($wParam, 16) ; Hi Word Switch $hWndFrom Case $hCombo_Handle Switch $iCode Case $CBN_EDITCHANGE ; Sent after the user has altered the text in the edit control portion of a combo box $sText = GUICtrlRead($hCombo) If StringLen($sText) > 10 Then $sText = StringMid($sText, 1, 10) _GUICtrlComboBox_SetEditText($hCombo, $sText) EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Share this post Link to post Share on other sites