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.