PcExpert Posted June 18, 2008 Share Posted June 18, 2008 (edited) Hi all, How to limit the amount of characters that can be entered into an edit control per line? Thanks! Edited June 18, 2008 by PcExpert Link to comment Share on other sites More sharing options...
PcExpert Posted June 18, 2008 Author Share Posted June 18, 2008 anybody? Link to comment Share on other sites More sharing options...
martin Posted June 18, 2008 Share Posted June 18, 2008 Hi all, How to limit the amount of characters that can be entered into an edit control per line? Thanks!Something like this might do what you want. expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Const $MAXLINELENGTH = 10 #Region ### START Koda GUI section ### Form= $Form3 = GUICreate("Form3", 413, 298, 303, 219) $Edit1 = GUICtrlCreateEdit("", 88, 16, 233, 193) GUICtrlSetData(-1, "Edit1") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Global $eText Global $hEd = GUICtrlGetHandle($Edit1) Global $checkLines = False GUIRegisterMsg($WM_COMMAND, "DB_WM_COMMAND") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch If $checkLines Then TestEdit() $checkLines = False EndIf WEnd Func TestEdit() Local $changed = False Local $eT = GUICtrlRead($Edit1) $aeT = StringSplit($eT, @CRLF) For $n = 1 To $aeT[0] If StringLen($aeT[$n]) > $MAXLINELENGTH Then $eT = StringReplace($eT, $aeT[$n], StringLeft($aeT[$n], $MAXLINELENGTH)) $changed = True EndIf Next If $changed Then GUICtrlSetData($Edit1, $eT) EndFunc ;==>TestEdit Func DB_WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) Local $setHK = False $nNotifyCode = BitShift($iwParam, 16) $nID = BitAND($iwParam, 0x0000FFFF) $hCtrl = $ilParam If $nNotifyCode = $EN_CHANGE Then If $ilParam = $hEd And Not $checkLines Then $checkLines = True EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>DB_WM_COMMAND 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 More sharing options...
PcExpert Posted June 18, 2008 Author Share Posted June 18, 2008 Thanks this works, but maybe there's another way around this? I'll try to explain: I want to make the edit so that, when the horizontal scrollbars are needed to see the remaining text on that line, it will automatically jump to the next line to avoid the need of the horizontal scrollbar. Thanks! Link to comment Share on other sites More sharing options...
martin Posted June 18, 2008 Share Posted June 18, 2008 Thanks this works, but maybe there's another way around this? I'll try to explain: I want to make the edit so that, when the horizontal scrollbars are needed to see the remaining text on that line, it will automatically jump to the next line to avoid the need of the horizontal scrollbar. Thanks!Hhhm. might have been a good idea to explain that at the start. Maybe this is the sort of thing you want $Edit1 = GUICtrlCreateEdit("", 88, 16, 233, 193, BitOR($ES_AUTOVSCROLL,$ES_WANTRETURN)) 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 More sharing options...
PcExpert Posted June 19, 2008 Author Share Posted June 19, 2008 You're right, I should have mentioned that earlier. The script works fine now. But the Verticalscrollbar is also missing. I'd like to have no horizontal scrollbar, but I'd like to have the verticalscrollbar. Any way to get it back? I tried removing $ES_AUTOVSCROLL but then the whole edit control got stuck . Thanks! Link to comment Share on other sites More sharing options...
rasim Posted June 19, 2008 Share Posted June 19, 2008 PcExpertMayb this?#include <GuiConstantsEx.au3> #include <EditConstants.au3> #include <GuiEdit.au3> $hGUI = GUICreate("Test", 300, 200) $edit = GUICtrlCreateEdit("Hello world", 10, 10, 280, 180, $ES_WANTRETURN) _GUICtrlEdit_SetMargins($edit, $EC_RIGHTMARGIN, 0, 100) GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Link to comment Share on other sites More sharing options...
PcExpert Posted June 20, 2008 Author Share Posted June 20, 2008 Thanks, that did it! Link to comment Share on other sites More sharing options...
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