Jump to content

Recommended Posts

Posted

Upon editing a rich text control, I often get what I'll call "phantom" or "artifact" cursors following text stings that I enter or paste in.  (see example, below)

Here is a minimum script that reproduces the problem:

;
;       Simple test of rich text "artifacts" upon editing
;
#include <WindowsConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>          ; only for i:note panel
#include <WinAPISys.au3>

Global $hP = GUICreate("", 0, 0, 0, 0, 0) ; , $WS_EX_TOOLWINDOW)        ; parent GUI is necessary to avoid taskbar icon
$hGUI = GUICreate("Rich Panel", 500, 260, -1, ((@DesktopHeight - 640) / 2) - 34, $WS_POPUP, BitOR($WS_EX_TOPMOST, $WS_EX_ACCEPTFILES), $hP)
GUISetBkColor(0xDBEFE6)
GUICtrlCreateLabel("", 10, 10, 474, 216)                            ; set a background for the text (keeps text from touching the edges)
GUICtrlSetBkColor(-1, 0xFFFFFF)
GUICtrlSetState(-1, $GUI_DISABLE)

$hRichEdit = _GUICtrlRichEdit_Create($hGUI, "", 20, 12, 462, 212, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL), $WS_EX_TRANSPARENT)
_GUICtrlRichEdit_SetText($hRichEdit, "This is sample text." & @CRLF & "Edit or cut/paste multiple times.")
_GUICtrlRichEdit_SetSel($hRichEdit, 0, -1)                          ; select all
_GUICtrlRichEdit_SetFont($hRichEdit, 14, "Segoe UI Semibold")   ; set all to Semibold
_GUICtrlRichEdit_SetSel($hRichEdit, 0, 0)                           ; deselect all

$iDone = GUICtrlCreateButton("Done", 400, 230, 72, 22)
GUICtrlSetTip(-1, "Click to exit")
GUICtrlSetFont(-1, 10)

GUISetState()

While 1
    $iMsg = GUIGetMsg()
    Switch $iMsg
        Case $iDone, $GUI_EVENT_CLOSE
            _GUICtrlRichEdit_Destroy($hRichEdit)
            GUIDelete($hGUI)
            Exit
    EndSwitch
WEnd

I'm running the latest AU3 on Win7 32-bit.

I will greatly appreciate any help in isolating the cause.  Thanks in advance.

 

Rich Text Artifacts.PNG

  • 2 weeks later...
Posted

I realize this effect might be due to something on my PC.

It would be helpful if someone would try my reproducer script. If it doesn't produce artifacts, I'll know which direction to look.

Thanks for any help.

 

Posted

Does it only happen with setsel?  Is this the same behavior of pressing ctrl+alt+arrowkey on a system with monitors that do not rotate?

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Posted

Thanks for your response.

I commented out the two SetSel statements and the artifact cursor still shows up.  Is that what you were suggesting?

 

Same Result.png

Posted

Interestingly, the rich text control seems to allow only one artifact per line.  If there is already one in a line, it will clear that one whenever one appears at a new position.

I also removed the SetFont statement and still have the effect.

 

Still happens.png

Posted

New result ...

Just to try things, I started removing flags in the RichEdit_Create ... first the scroll flags ... and finally, the $WS_EX_TRANSPARENT.

Without the transparent background, the artifact cursors never show up.  The problem is that I get the unsightly border than I need to avoid.

Any idea how to be rid of the border?  (... or fix the transparent effect, of course)

 

Does Not Happen.png

 

Posted
Posted
Quote

Does $WS_EX_WINDOWEDGE work?

Indeed, it does solve the artifact problem ... but it introduces another problem, albeit a minor one: the end controls of the scroll bar don't show up when the bar first appears.

I've never used WindowEdge, before, so it's unclear to me 1) what it usually does and 2) why there is no border in this use.

Regardless, I tried adding it with $WS_EX_TRANSPARENT and the artifacts come back.  But by itself, it does work.  So, maybe someone will have a idea about the scroll bar control.

Thanks for your assistance!

 

Minor Problem.png

Posted
Quote

Does $WS_EX_WINDOWEDGE work?

More testing has revealed a problem that I just can't get around: every now and then, pasting text into the control causes the control to foul up the displayed content. Blank areas appear over the text, as if it's displaying content from the wrong lines. Characters are really there, because if a character is typed into a blank area, they appear.

This is such a low level problem that I'm not going to try for a workaround. There are just too many possibilities for losing content and not noticing.

Instead, I'm going to go back to the transparent background, but add a refresh feature that clears any artifacts. The following statement does that perfectly and doesn't change the scrolling. 

Quote

        _WinAPI_SetWindowPos($hRichEdit, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE))

I'll consider this "Case Closed".  Thanks for the responses.

 

Content Problem.png

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...