Jump to content
Sign in to follow this  

Selection goes invisible after _GUICtrlRichEdit_GetFont

Recommended Posts

In a RichEdit control, the selection goes invisible (not the text, the highlighting) after using UDF _GUICtrlRichEdit_GetFont.  The selection remains invisible even if _GUICtrlRichEdit_SetSel is used afterwards.  The script below will demonstrate this. 
Run the script and click the button to get started.  A series of message boxes will pause the script at each step for verification.
Can someone please confirm this.
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $hRichEdit, $hGui, $iMsg, $btnNext, $aFontAtts
$hGui = GUICreate("_GUICtrlRichEdit_GetFont", 300, 150, (@DesktopWidth - 300) / 2, 100)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "Selection NOT visible after _GUICtrlRichEdit_GetFont", 10, 10, 300, 90, BitOR($ES_MULTILINE, $ES_NOHIDESEL))
$btnNext = GUICtrlCreateButton(" Click Me To Start ", 110, 110)
While True
    $iMsg = GUIGetMsg()
        Case $iMsg = $GUI_EVENT_CLOSE
        Case $iMsg = $btnNext
            GUICtrlSetState($btnNext, $GUI_DISABLE)
            _GUICtrlRichEdit_SetSel($hRichEdit, 0, 9) ; <<<< Selection is visible.
            MsgBox(4096, "1", "The word 'Selection' should be visually selected!")

            $aFontAtts = _GUICtrlRichEdit_GetFont($hRichEdit) ; <<<< Causes selection to go invisible.
            MsgBox(4096, "2", _
                    "The UFD _GUICtrlRichEdit_GetFont function was called." & @LF & _
                    "Is the word 'Selection' still visually selected?" & @LF & _
                    "It should be, but it's not." & @LF & _
                    @LF & _
                    "It's actually selected, although not visually." & @LF & _
                    @LF & _
                    "Click OK to do _GUICtrlRichEdit_SetSel($hRichEdit, 0, 9).")

            _GUICtrlRichEdit_SetSel($hRichEdit, 0, 9) ; <<<< Setting Seletion again does not make selecion visible.
            ;  _GUICtrlRichEdit_SetSel($hRichEdit, 0, 9, False) ; <<<< Setting Seletion again does not make selecion visible.
            MsgBox(4096, "3", _
                    "Is the word 'Selection' selected?" & @LF & _
                    "_GUICtrlRichEdit_SetSel($hRichEdit, 0, 9) was called" & @LF & _
                    "but the selection is still invisible." & @LF & _
                    @LF & _
                    "Even if _GUICtrlRichEdit_SetSel($hRichEdit, 0, 9, False)" & @LF & _
                    "is called, the selection is still invisible." & @LF & _
                    @LF & _
                    "Click OK and it's back to visually selected (I don't know why).")



Share this post

Link to post
Share on other sites

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

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.