Reinhardt Posted April 17, 2006 Posted April 17, 2006 I'm making a program and i need to limit line length on a multiline edit box. I've done some searching within AutoIt help file and within the forum and couldn't find anything... So can anyone help me out?
Valuater Posted April 17, 2006 Posted April 17, 2006 #include <GUIConstants.au3> GUICreate("My GUI limit editbox") ; will create a dialog box that when displayed is centered GUICtrlCreateEdit("", 10,20, 300, 200) GUICtrlSetLimit(-1,40); to limit the entry to 3 chars GUISetState () ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend 8)
GaryFrost Posted April 17, 2006 Posted April 17, 2006 Requires beta expandcollapse popup#include <GUIConstants.au3> #include <GuiEdit.au3> Opt('MustDeclareVars', 1) Dim $myedit, $Status, $msg, $s_rect, $label_rect, $rect_array GUICreate("Edit Line Length", 392, 254) $myedit = GUICtrlCreateEdit("AutoIt v3 is a freeware BASIC-like scripting language designed for automating the Windows GUI. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation" & @CRLF, 10, 32, 171, 97, BitOR($ES_AUTOVSCROLL, $WS_VSCROLL, $ES_MULTILINE)) GUICtrlSetLimit($myedit, 1500) $label_rect = GUICtrlCreateLabel($s_rect, 195, 50, 100, 55, $SS_SUNKEN) GUISetState() $rect_array = _GUICtrlEditGetRECT($myedit) If ($rect_array == $EC_ERR) Then MsgBox(0, "Error", "Unable to Get RECT") ElseIf (IsArray($rect_array)) Then $s_rect = "Left:" & $rect_array[1] & @LF & "Top:" & $rect_array[2] & @LF & "Right:" & $rect_array[3] & @LF & "Bottom:" & $rect_array[4] GUICtrlSetData($label_rect, $s_rect) EndIf Sleep(1000) _GuiCtrlEditSetRect($myedit, 0, 0, 80, $rect_array[4]) Sleep(1000) $rect_array = _GUICtrlEditGetRECT($myedit) If ($rect_array == $EC_ERR) Then MsgBox(0, "Error", "Unable to Get RECT") ElseIf (IsArray($rect_array)) Then $s_rect = "Left:" & $rect_array[1] & @LF & "Top:" & $rect_array[2] & @LF & "Right:" & $rect_array[3] & @LF & "Bottom:" & $rect_array[4] GUICtrlSetData($label_rect, $s_rect) EndIf ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd ;=============================================================================== ; ; Description: _GUICtrlEditSetRECT ; Parameter(s): $h_edit - controlID ; Requirement: None ; Return Value(s): None ; User CallTip: _GUICtrlEditSetRECT(Byref $h_edit, $left, $top, $right, $bottom) Sets the formatting rectangle of an edit control. (required: <GuiEdit.au3>) ; Author(s): Gary Frost (custompcs at charter dot net) ; Note(s): ; ;=============================================================================== Func _GuiCtrlEditSetRect(ByRef $h_edit, $left, $top, $right, $bottom) Local Const $EM_SETRECT = 0xB3 Local $struct = DllStructCreate("int;int;int;int") DllStructSetData($struct, 1, $left) DllStructSetData($struct, 2, $top) DllStructSetData($struct, 3, $right + 1) DllStructSetData($struct, 4, $bottom + 10) If IsHWnd($h_edit) Then DllCall("user32.dll", "none", "SendMessage", "hwnd", $h_edit, "int", $EM_SETRECT, "int", 0, "ptr", DllStructGetPtr($struct)) Else GUICtrlSendMsg($h_edit, $EM_SETRECT, 0, DllStructGetPtr($struct)) EndIf EndFunc ;==>_GuiCtrlEditSetRect SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now