Loc Posted October 19, 2021 Posted October 19, 2021 Although disabled state for guictrlcreatepic has been set, when _GUICtrlRichEdit_Create enters the text box with full characters, it will disappear by itself (not manually entered text) and continue to be entered more, it will gradually appear from bottom to top but now the 2 Up Down buttons have been sunk until we hover over it to reappear. The border around this GUIEdit also disappears. Is there any way to fix this problem?
sudeepjd Posted October 19, 2021 Posted October 19, 2021 Please provide the code that you have created so that the GUI and the issue can be replicated so that anyone trying to answer your question and can help further. Without the code snippet to replicate, it will be difficult for us to understand what issue you are facing.
Loc Posted October 20, 2021 Author Posted October 20, 2021 Here is my snippet when I encountered this problem! expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GUIEdit.au3> #include <GuiRichEdit.au3> $Main = GUICreate("Test Edit", 436, 379) $IMGPic = GUICtrlCreatePic(@ScriptDir & '\IMGPic.jpg', 0,0, 436, 379) GUICtrlSetState(-1, 128) $Edit = _GUICtrlRichEdit_Create($Main, '', 24, 24, 385, 217, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY)) $ButtonTest = GUICtrlCreateButton("Test Error", 168, 288, 115, 41) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonTest _TestEdit() EndSwitch WEnd Func _TestEdit() _EditSetText(0x000000, 11, 'Time new romans', 'Test11111111') EndFunc Func _EditSetText($color, $Editfont, $editfontname, $Edittext, $bkcolor = 0xFFFFFF) _GUICtrlRichEdit_SetSel($Edit, -1, -1) _GUICtrlRichEdit_SetBkColor($Edit, __Color($bkcolor)) _GUICtrlRichEdit_SetCharColor($Edit, __Color($color)) _GUICtrlRichEdit_SetFont($Edit, $Editfont, $editfontname) _GUICtrlRichEdit_AppendText($Edit, $Edittext & @CRLF) _GUICtrlRichEdit_Deselect($Edit) EndFunc Func __Color($iColor) Local $sH = Hex($iColor, 6) Return '0x' & StringRight($sH, 2) & StringMid($sH, 3, 2) & StringLeft($sH, 2) EndFunc ;==>RGB2BGR I will attach the code and image in the zip file below Edit.zip
Zedna Posted October 20, 2021 Posted October 20, 2021 On my PC your code works fine without any visual problems. Loc 1 Resources UDF ResourcesEx UDF AutoIt Forum Search
Loc Posted October 20, 2021 Author Posted October 20, 2021 Have you tried pressing the Test Error button when it enters the new page 😰
Zedna Posted October 20, 2021 Posted October 20, 2021 (edited) Of course YES. Sorry, now I realized that you have to press button many times to fill RichEdit to vertical scrollbar appear and then visual problem appears. Workaround for this would be something like to call _WinAPI_InvalidateRect() everytime after modifying text of RichEdit, where Rect must contain also VScrollBar area. Later I will post this workaround ... Edited October 20, 2021 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Zedna Posted October 20, 2021 Posted October 20, 2021 (edited) Here is first dirty workaround, look at RichEdit_Refresh(): note: width of V scrollbar is here defined hard as 25 pixels expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GUIEdit.au3> #include <GuiRichEdit.au3> $Main = GUICreate("Test Edit", 436, 379) $IMGPic = GUICtrlCreatePic(@ScriptDir & '\IMGPic.jpg', 0,0, 436, 379) GUICtrlSetState(-1, 128) $Edit = _GUICtrlRichEdit_Create($Main, '', 24, 24, 385, 217, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY)) $ButtonTest = GUICtrlCreateButton("Test Error", 168, 288, 115, 41) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonTest _TestEdit() EndSwitch WEnd Func _TestEdit() _EditSetText(0x000000, 11, 'Time new romans', 'Test11111111') RichEdit_Refresh() EndFunc Func _EditSetText($color, $Editfont, $editfontname, $Edittext, $bkcolor = 0xFFFFFF) _GUICtrlRichEdit_SetSel($Edit, -1, -1) _GUICtrlRichEdit_SetBkColor($Edit, __Color($bkcolor)) _GUICtrlRichEdit_SetCharColor($Edit, __Color($color)) _GUICtrlRichEdit_SetFont($Edit, $Editfont, $editfontname) _GUICtrlRichEdit_AppendText($Edit, $Edittext & @CRLF) _GUICtrlRichEdit_Deselect($Edit) EndFunc Func __Color($iColor) Local $sH = Hex($iColor, 6) Return '0x' & StringRight($sH, 2) & StringMid($sH, 3, 2) & StringLeft($sH, 2) EndFunc ;==>RGB2BGR Func RichEdit_Refresh() $pos = ControlGetPos($Main, '', $Edit) Local $tRect = DllStructCreate($tagRECT) DllStructSetData($tRect, 'Right', $pos[2]+25) ; just test: add width of VScrollBar to area to be invalidating DllStructSetData($tRect, 'Bottom', $pos[3]+25) _WinAPI_InvalidateRect($Main, $tRECT, False) ; Erase=False EndFunc Edited October 20, 2021 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Zedna Posted October 20, 2021 Posted October 20, 2021 Here is Rect of Richedit defined as global and determined only once at start: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Include <GUIEdit.au3> #include <GuiRichEdit.au3> $Main = GUICreate("Test Edit", 436, 379) $IMGPic = GUICtrlCreatePic(@ScriptDir & '\IMGPic.jpg', 0,0, 436, 379) GUICtrlSetState(-1, 128) $Edit = _GUICtrlRichEdit_Create($Main, '', 24, 24, 385, 217, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY)) $ButtonTest = GUICtrlCreateButton("Test Error", 168, 288, 115, 41) GUISetState(@SW_SHOW) Global $RichEdit_pos = ControlGetPos($Main, '', $Edit) Global $RichEdit_Rect = DllStructCreate($tagRECT) DllStructSetData($RichEdit_Rect, 'Right', $RichEdit_pos[2]+25) ; just test: add width of VScrollBar to area to be invalidating DllStructSetData($RichEdit_Rect, 'Bottom', $RichEdit_pos[3]+25) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $ButtonTest _TestEdit() EndSwitch WEnd Func _TestEdit() _EditSetText(0x000000, 11, 'Time new romans', 'Test11111111') RichEdit_Refresh() EndFunc Func _EditSetText($color, $Editfont, $editfontname, $Edittext, $bkcolor = 0xFFFFFF) _GUICtrlRichEdit_SetSel($Edit, -1, -1) _GUICtrlRichEdit_SetBkColor($Edit, __Color($bkcolor)) _GUICtrlRichEdit_SetCharColor($Edit, __Color($color)) _GUICtrlRichEdit_SetFont($Edit, $Editfont, $editfontname) _GUICtrlRichEdit_AppendText($Edit, $Edittext & @CRLF) _GUICtrlRichEdit_Deselect($Edit) EndFunc Func __Color($iColor) Local $sH = Hex($iColor, 6) Return '0x' & StringRight($sH, 2) & StringMid($sH, 3, 2) & StringLeft($sH, 2) EndFunc ;==>RGB2BGR Func RichEdit_Refresh() _WinAPI_InvalidateRect($Main, $RichEdit_Rect, False) ; Erase=False EndFunc Loc 1 Resources UDF ResourcesEx UDF AutoIt Forum Search
Zedna Posted October 20, 2021 Posted October 20, 2021 (edited) Just one interesting info: Without my workaround you can avoid dissapearing of RichEdit by setting WS_EX_TOPMOST ExStyle: $Edit = _GUICtrlRichEdit_Create($Main, '', 24, 24, 385, 217, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY), $WS_EX_TOPMOST) But problem with not repainting of vertical scrollbar remains ... (without my workaround) 2) In I firstly tried more simple workaround in Func RichEdit_Refresh() _WinAPI_InvalidateRect($Edit, 0, False) ; Erase=False but it didn't helped with bad repainting of V scrollbar so I ended up with my more complicated workaround using _WinAPI_InvalidateRect($Main, $RichEdit_Rect, False) ; Erase=False Edited October 20, 2021 by Zedna Loc 1 Resources UDF ResourcesEx UDF AutoIt Forum Search
Loc Posted October 21, 2021 Author Posted October 21, 2021 Wow... Thank you so much for taking so much time to solve this problem ❤️
Zedna Posted October 22, 2021 Posted October 22, 2021 (edited) Here is fix for my last script, there was badly filled Rect structure: Original bad code: Global $RichEdit_pos = ControlGetPos($Main, '', $Edit) Global $RichEdit_Rect = DllStructCreate($tagRECT) DllStructSetData($RichEdit_Rect, 'Right', $RichEdit_pos[2]+25) DllStructSetData($RichEdit_Rect, 'Bottom', $RichEdit_pos[3]+25) By coincidence this bug wasn't problem here because Left/Top position of RichEdit is 24/24 and I used +25/+25 as correction mistakingly fo width/height of Scrollbars. You can test it, problem occurs when you increase RichEdit's X position (X=24 -> X=34). Correct fix is this: Global $RichEdit_pos = ControlGetPos($Main, '', $Edit) Global $RichEdit_Rect = DllStructCreate($tagRECT) DllStructSetData($RichEdit_Rect, 'Left', $RichEdit_pos[0]) DllStructSetData($RichEdit_Rect, 'Top', $RichEdit_pos[1]) DllStructSetData($RichEdit_Rect, 'Right', $RichEdit_pos[0]+$RichEdit_pos[2]) DllStructSetData($RichEdit_Rect, 'Bottom', $RichEdit_pos[1]+$RichEdit_pos[3]) With this fix RichEdit will be correctly repainted (including its H/V scrollbars) no matter of it's position inside main window. Edited October 22, 2021 by Zedna Loc 1 Resources UDF ResourcesEx UDF AutoIt Forum Search
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