martin Posted May 6, 2011 Share Posted May 6, 2011 The following script has 2 edits. there are 2 variables which are set to equalk the 2 edits. If I switch the variables to point to the other edits then the first text which is added to th eedit replaces the previous text. I don'yt understand this so maybe someone can either point out what I should be seeing but can't or tell me they think the behaviour is wrong. expandcollapse popup#include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <guiedit.au3> #region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 613, 298, 302, 218) $Edit1 = GUICtrlCreateEdit("", 119, 46, 185, 204) GUICtrlSetData(-1, "Edit1") $Edit2 = GUICtrlCreateEdit("", 318, 46, 185, 204) GUICtrlSetData(-1, "Edit2") GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### ;GUICtrlSetState($Edit2, $GUI_HIDE) Local $sA, $sB, $startA, $startB $count = 0 $startA = 0 $startB = 50 $Eda = $Edit1 $EdB = $Edit2 $add = True While 1 $msg = GUIGetMsg() If $msg = -3 Then Exit If $add Then $count += 1 $s = "------------> " & $count & @CRLF GUICtrlSetData($Eda, $s, "1") If $count > 50 Then GUICtrlSetData($EdB, $s, "1") If $count > $startB + 100 Then ;ConsoleWrite($Eda & ', ' & $EdB & @CRLF) _SwitchSeens($Eda, $EdB) ;ConsoleWrite($Eda & ', ' & $EdB & @CRLF) GUICtrlSetData($Edb, '') ConsoleWrite(GUICtrlRead($EdA) & @CRLF);this shows the data correctly GUICtrlSetData($Eda, $s, "1");first write to add a new line seems to destroy old data ConsoleWrite("+++++++++++++++ should have same again plus last line repeated ++++++++++++++++++++++++++++" & @CRLF) ConsoleWrite(GUICtrlRead($EdA) & @CRLF);data gone!! exit ; sulk $startB = $count + 50 EndIf EndIf Sleep(100) WEnd Func _SwitchSeens(ByRef $Edj, ByRef $Edk) Local $temp, $sF $temp = $Edj $Edj = $Edk $Edk = $temp ;$sF = _GUICtrlEdit_GetFirstVisibleLine($Edj) GUICtrlSetState($Edj, $GUI_SHOW) ;sleep(4000) GUICtrlSetState($Edk, $GUI_HIDE) ;sleep(9000) EndFunc ;==>_SwitchSeens 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...
rover Posted May 7, 2011 Share Posted May 7, 2011 Hello Martin It looks like an issue with GUICtrlSetState(), when it is used with $GUI_HIDE on an edit control. If you disable and hide the edit, it solves this problem. Report to Trac? GUICtrlSetState($Edj, $GUI_ENABLE+$GUI_SHOW) GUICtrlSetState($Edk, $GUI_DISABLE+$GUI_HIDE) I see fascists... Link to comment Share on other sites More sharing options...
martin Posted May 7, 2011 Author Share Posted May 7, 2011 (edited) Hello Martin It looks like an issue with GUICtrlSetState(), when it is used with $GUI_HIDE on an edit control. If you disable and hide the edit, it solves this problem. Report to Trac? GUICtrlSetState($Edj, $GUI_ENABLE+$GUI_SHOW) GUICtrlSetState($Edk, $GUI_DISABLE+$GUI_HIDE) Hi Rover, Thanks for that. I'll play with your finding and then I'll post a bug report. EDIT: Rover, although you're right that adding $GUI_DISABLE fixes the problem, I can't make a simple repoducer to show that hiding the edit can make it loose data. The code below works as expected. expandcollapse popup[ #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <guiedit.au3> opt("GUIONEVENTMODE",1) #region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 443, 298, 302, 218) $Edit1 = GUICtrlCreateEdit("", 119, 46, 185, 204) GUICtrlSetData(-1, "Edit1") $BtnAdd = GUICtrlCreateButton("add line to edit", 10, 100) GUICtrlSetOnEvent(-1,"BtnAddClick") $BtnHide_Show = GUICtrlCreateButton("Hide/Show edit", 10, 150) GUICtrlSetOnEvent(-1,"BtnHideShowClick") GUISetState(@SW_SHOW) GUISetOnEvent($GUI_EVENT_CLOSE,"Finished") #endregion ### END Koda GUI section ### ;GUICtrlSetState($Edit2, $GUI_HIDE) $Show = $GUI_SHOW $count = 1 While 1 Sleep(100) WEnd func finished() Exit EndFunc func BtnAddClick() GUICtrlSetData($Edit1, "---> " & $count & @CRLF, "1") $count += 1 EndFunc func BtnHideShowClick() $Show = $GUI_HIDE + $GUI_SHOW - $Show;toggle GUICtrlSetState($Edit1, $Show) EndFunc Any suggestions? Edited May 7, 2011 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 More sharing options...
rover Posted May 7, 2011 Share Posted May 7, 2011 You need two edit controls to get this result. The problem only occurs if the first edit control created is hidden, as in your _SwitchSeens() function, then the second edit control has text appended. Any other combination of edit controls appends normally. only the edit1-hidden, edit2-append arrangement has this result. Once edit1 is hidden, additional text appends normally to edit2 The reproducer shows that if edit 1 is re-shown, then re-hidden, edit 2's text will still be cleared when a line is appended. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Local $add = True, $s GUICreate("Form2", 400, 298, 302, 218) Local $Edit1 = GUICtrlCreateEdit("Edit1", 10, 46, 120, 204) Local $Edit2 = GUICtrlCreateEdit("Edit2", 140, 46, 120, 204) ;Local $Edit3 = GUICtrlCreateEdit("Edit3", 270, 46, 120, 204) GUISetState(@SW_SHOW) For $i = 0 To 6 $s &= "------------> " & $i & @CRLF Next While GUIGetMsg() <> -3 If $add Then GUICtrlSetData($Edit2, $s, "1") Sleep(2000) GUICtrlSetState($Edit1, $GUI_HIDE);text cleared from edit 2, when line appended ;GUICtrlSetState($Edit1, $GUI_HIDE+$GUI_DISABLE) ; text appended to edit 2 GUICtrlSetData($Edit2, "------------> 6" & @CRLF, "1") Sleep(2000) GUICtrlSetData($Edit2, "") GUICtrlSetState($Edit1, $GUI_SHOW) GUICtrlSetData($Edit2, $s, "1") Sleep(2000) GUICtrlSetState($Edit1, $GUI_HIDE);text cleared from edit 2, when line appended ;GUICtrlSetState($Edit1, $GUI_HIDE+$GUI_DISABLE) ; text appended to edit 2 GUICtrlSetData($Edit2, "------------> 6" & @CRLF, "1") $add = False EndIf WEnd Exit I see fascists... Link to comment Share on other sites More sharing options...
martin Posted May 7, 2011 Author Share Posted May 7, 2011 (edited) You need two edit controls to get this result. The problem only occurs if the first edit control created is hidden, as in your _SwitchSeens() function, then the second edit control has text appended. Any other combination of edit controls appends normally. only the edit1-hidden, edit2-append arrangement has this result. Once edit1 is hidden, additional text appends normally to edit2 The reproducer shows that if edit 1 is re-shown, then re-hidden, edit 2's text will still be cleared when a line is appended. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Opt("MustDeclareVars", 1) Local $add = True, $s GUICreate("Form2", 400, 298, 302, 218) Local $Edit1 = GUICtrlCreateEdit("Edit1", 10, 46, 120, 204) Local $Edit2 = GUICtrlCreateEdit("Edit2", 140, 46, 120, 204) ;Local $Edit3 = GUICtrlCreateEdit("Edit3", 270, 46, 120, 204) GUISetState(@SW_SHOW) For $i = 0 To 6 $s &= "------------> " & $i & @CRLF Next While GUIGetMsg() <> -3 If $add Then GUICtrlSetData($Edit2, $s, "1") Sleep(2000) GUICtrlSetState($Edit1, $GUI_HIDE);text cleared from edit 2, when line appended ;GUICtrlSetState($Edit1, $GUI_HIDE+$GUI_DISABLE) ; text appended to edit 2 GUICtrlSetData($Edit2, "------------> 6" & @CRLF, "1") Sleep(2000) GUICtrlSetData($Edit2, "") GUICtrlSetState($Edit1, $GUI_SHOW) GUICtrlSetData($Edit2, $s, "1") Sleep(2000) GUICtrlSetState($Edit1, $GUI_HIDE);text cleared from edit 2, when line appended ;GUICtrlSetState($Edit1, $GUI_HIDE+$GUI_DISABLE) ; text appended to edit 2 GUICtrlSetData($Edit2, "------------> 6" & @CRLF, "1") $add = False EndIf WEnd Exit Rover, you have a line GUICtrlSetData($Edit2, "") which removes the text so that shouldn't be there. I think the bug is to do with the selected text in Edit2 being changed by hiding and showing Edit1. If you use _GUICtrlEdit_AppendText then there is no problem. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <guiedit.au3> Opt("MustDeclareVars", 1) Local $add = True, $s GUICreate("Form2", 400, 298, 302, 218) Local $Edit1 = GUICtrlCreateEdit("Edit1", 10, 46, 120, 204) Local $Edit2 = GUICtrlCreateEdit("Edit2", 140, 46, 120, 204) GUISetState(@SW_SHOW) For $i = 0 To 6 $s &= "------------> " & $i & @CRLF Next While GUIGetMsg() <> -3 If $add Then GUICtrlSetData($Edit2, $s, "1") Sleep(2000) GUICtrlSetState($Edit1, $GUI_HIDE);text cleared from edit 2, when line appended ;GUICtrlSetData($Edit2, "------------> 6 <--should be a duplicate number" & @CRLF, "1") _GUICtrlEdit_AppendText($Edit2, "---another--> 6" & @CRLF) Sleep(2000) ; GUICtrlSetData($Edit2, "") GUICtrlSetState($Edit1, $GUI_SHOW) GUICtrlSetData($Edit2, $s, "1 ") Sleep(2000) GUICtrlSetState($Edit1, $GUI_HIDE);text cleared from edit 2, when line appended ;GUICtrlSetData($Edit2, "------------> 6" & @CRLF, "1") _GUICtrlEdit_AppendText($Edit2, "-------------> end??") Sleep(2000) GUICtrlSetState($Edit1, $GUI_SHOW) $add = False EndIf ;#ce WEnd Anyway, it is incorrect behaviour so I'll report it as a bug EDIT: trac ref #1924 Edited May 7, 2011 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 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