Zag8888 Posted June 8, 2019 Share Posted June 8, 2019 (edited) Hello to all I want to add text in a read-only edit control. When I highlight using the mouse in Edit box I can change the position of outputted words, how can I fix this? I think that the problem is from GuiCtrlSetData() #include <GuiEdit.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> Global $hGUI,$Exit Local $logs, $String ReadOnlyGUI() Func ReadOnlyGUI() Opt("GUIOnEventMode", 1) $hGUI=GuiCreate("Test", 625, 480, -1, -1, $WS_CAPTION + $WS_SYSMENU + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_MINIMIZEBOX + $WS_EX_TOOLWINDOW) GUISetOnEvent($GUI_EVENT_CLOSE,"Exits") GUISwitch($hGUI) GUISetState(@SW_SHOW, $hGui) Global $ReadOnly = GUICtrlCreateEdit(" ReadOnly" & @CRLF, 400, 50, 200, 400, + $ES_READONLY + $ES_MULTILINE + $WS_BORDER + $ES_AUTOVSCROLL ) GUICtrlSetStyle($ReadOnly, 0) EndFunc Func SetLogs($String) $logs = " " & $String GUICtrlSetData($ReadOnly, $logs & @CRLF,1) EndFunc Func Exits() Exit EndFunc while 1 Sleep(1000) SetLogs("Testing") WEnd Best Regards Edited June 13, 2019 by Zag8888 Link to comment Share on other sites More sharing options...
Zag8888 Posted June 8, 2019 Author Share Posted June 8, 2019 (edited) Edit: Fixed by using _GUICtrlEdit_AppendText() instead of GuiCtrlSetData() I still have the problem, but now works better. 2 Edit: I used _GUICtrlEdit_InsertText instead of GuiCtrlSetData() and I removed GUICtrlSetStyle($ReadOnly, 0) Now its work perfect. Edited June 8, 2019 by Zag8888 Link to comment Share on other sites More sharing options...
Zedna Posted June 9, 2019 Share Posted June 9, 2019 Here is more simple solution without _GUICtrlEdit_xxxx(): #include <GuiEdit.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> Global $hGUI, $Exit Local $logs, $String ReadOnlyGUI() Func ReadOnlyGUI() Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Test", 625, 480, -1, -1, $WS_CAPTION + $WS_SYSMENU + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_MINIMIZEBOX + $WS_EX_TOOLWINDOW) GUISetOnEvent($GUI_EVENT_CLOSE, "Exits") GUISetState(@SW_SHOW, $hGUI) Global $ReadOnly = GUICtrlCreateEdit(" ReadOnly" & @CRLF, 400, 50, 200, 400, +$ES_READONLY + $ES_MULTILINE + $WS_BORDER + $ES_AUTOVSCROLL) GUICtrlSetStyle($ReadOnly, 0) EndFunc ;==>ReadOnlyGUI Func SetLogs($String) $logs = GUICtrlRead($ReadOnly) $logs &= @CRLF & " " & $String GUICtrlSetData($ReadOnly, $logs) EndFunc ;==>SetLogs Func Exits() Exit EndFunc ;==>Exits While 1 Sleep(1000) SetLogs("Testing") WEnd Zag8888 1 Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zag8888 Posted June 9, 2019 Author Share Posted June 9, 2019 Great, thanks a lot Link to comment Share on other sites More sharing options...
Zag8888 Posted June 9, 2019 Author Share Posted June 9, 2019 (edited) 19 hours ago, Zedna said: Here is more simple solution without _GUICtrlEdit_xxxx(): #include <GuiEdit.au3> #include <Constants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> Global $hGUI, $Exit Local $logs, $String ReadOnlyGUI() Func ReadOnlyGUI() Opt("GUIOnEventMode", 1) $hGUI = GUICreate("Test", 625, 480, -1, -1, $WS_CAPTION + $WS_SYSMENU + $WS_VISIBLE + $WS_CLIPSIBLINGS + $WS_MINIMIZEBOX + $WS_EX_TOOLWINDOW) GUISetOnEvent($GUI_EVENT_CLOSE, "Exits") GUISetState(@SW_SHOW, $hGUI) Global $ReadOnly = GUICtrlCreateEdit(" ReadOnly" & @CRLF, 400, 50, 200, 400, +$ES_READONLY + $ES_MULTILINE + $WS_BORDER + $ES_AUTOVSCROLL) GUICtrlSetStyle($ReadOnly, 0) EndFunc ;==>ReadOnlyGUI Func SetLogs($String) $logs = GUICtrlRead($ReadOnly) $logs &= @CRLF & " " & $String GUICtrlSetData($ReadOnly, $logs) EndFunc ;==>SetLogs Func Exits() Exit EndFunc ;==>Exits While 1 Sleep(1000) SetLogs("Testing") WEnd I've tried to use _GUICtrlRichEdit_Create_ instead of GUICtrlCreateEdit, I found _GUICtrlRichEdit_Create_ better, I've used _GUICtrlRichEdit_AppendText to add text, but with the mouse, I can move all the outputted words. Edited June 9, 2019 by Zag8888 Link to comment Share on other sites More sharing options...
Zag8888 Posted June 10, 2019 Author Share Posted June 10, 2019 bb Link to comment Share on other sites More sharing options...
Zag8888 Posted June 11, 2019 Author Share Posted June 11, 2019 bb Link to comment Share on other sites More sharing options...
Developers Jos Posted June 11, 2019 Developers Share Posted June 11, 2019 bb? Is there still a question in the topic ( which you marked as Solved in the title) ? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Zedna Posted June 12, 2019 Share Posted June 12, 2019 (edited) On 6/9/2019 at 10:12 PM, Zag8888 said: I've tried to use _GUICtrlRichEdit_Create_ instead of GUICtrlCreateEdit, I found _GUICtrlRichEdit_Create_ better, I've used _GUICtrlRichEdit_AppendText to add text, but with the mouse, I can move all the outputted words. Post small reproducing script to increase your chance for getting help ... EDIT: As far as I think you want to completely disable richedit control and use it only as LOG output? Edited June 12, 2019 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
Zag8888 Posted June 13, 2019 Author Share Posted June 13, 2019 On 6/12/2019 at 11:10 AM, Zedna said: Post small reproducing script to increase your chance for getting help ... EDIT: As far as I think you want to completely disable richedit control and use it only as LOG output? right! I'm trying to make a log output Link to comment Share on other sites More sharing options...
Zag8888 Posted June 13, 2019 Author Share Posted June 13, 2019 (edited) On 6/11/2019 at 9:47 PM, Jos said: bb? Is there still a question in the topic ( which you marked as Solved in the title) ? Jos Now its solved Edited June 13, 2019 by Zag8888 Link to comment Share on other sites More sharing options...
Zag8888 Posted June 13, 2019 Author Share Posted June 13, 2019 On 6/12/2019 at 11:10 AM, Zedna said: Post small reproducing script to increase your chance for getting help ... EDIT: As far as I think you want to completely disable richedit control and use it only as LOG output? I followed your last example. Now it works perfect, thanks for your help. Func SetLogs($String) $logs = _GUICtrlRichEdit_GetText($ReadOnly) $logs &= @CRLF & "[" & _NowTime() & "] " & $String _GUICtrlRichEdit_SetText($ReadOnly, $logs) EndFunc 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