Jump to content

Selection goes invisible after _GUICtrlRichEdit_GetFont


ILLBeBack
 Share

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)
GUISetState()
While True
    $iMsg = GUIGetMsg()
    Select
        Case $iMsg = $GUI_EVENT_CLOSE
            _GUICtrlRichEdit_Destroy($hRichEdit)
            Exit
        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).")
    EndSelect
WEnd

Exit

 

Link to comment
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
 Share

  • Recently Browsing   0 members

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