Opened 10 years ago

Closed 10 years ago

#2486 closed Bug (Fixed)

_GUICtrlRichEdit_GetFont does not return an empty string for mixed fonts

Reported by: ILLBeBack Owned by: Jpm
Milestone: Component: Standard UDFs
Version: Severity: None
Keywords: _GUICtrlRichEdit_GetFont Cc:


According to the doc, _GUICtrlRichEdit_GetFont should return an empty string when the selection contains mixed font. This makes sense, and is similar to what happens in VB for RichText. However, this is not what happens. Instead, the name of the font at the start of the selection is returned (depends on direction of selection).

The example script below will demonstrate this. When started, the 3 lines of text in the RichEdit box will be selected. Each line is a different font face. WIth all 3 lines selected, click the button to show the font face (in the label below the RichEdit) that is returned by _GUICtrlRichEdit_GetFont.

It also demonstrates a second issue, that being the inability to make another selection after _GUICtrlRichEdit_GetFont is used.

Note: The 2nd issue is related to the “invisible selection” issue reported as "Selection goes invisible after _GUICtrlRichEdit_GetFont".

#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $lblMsg, $hRichEdit


Func Example()
    Local $hGui, $iMsg, $btnNext, $sMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 370, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is the default font of this RichEdit box." & @CR, 10, 10, 330, 120, _
    $lblMsg = GUICtrlCreateLabel(@LF & "Leave all text selected and click the button.", 10, 135, 330, 175)
    GUICtrlSetBkColor(-1, 0xffffd5)
    $btnNext = GUICtrlCreateButton("  Click Me to list the font face of the selection  ", 75, 320)
    _GUICtrlRichEdit_SetFont($hRichEdit, 15, "Comic Sans MS")
    _GUICtrlRichEdit_AppendText($hRichEdit, "This is Comic Sans MS" & @CR)
    _GUICtrlRichEdit_SetFont($hRichEdit, 15, "Times New Roman")
    _GUICtrlRichEdit_AppendText($hRichEdit, "This is Times New Roman" & @CR)
    _GUICtrlRichEdit_SetSel($hRichEdit, 0, 100, False)

    While True
        $iMsg = GUIGetMsg()
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
            Case $iMsg = $btnNext
                Local $aRet = _GUICtrlRichEdit_GetFont($hRichEdit)
                $sMsg = "The selection is font face " & $aRet[1] & "," & @LF & _
                                "but there are 3 fonts in the selection, and _GUICtrlRichEdit_GetFont" & @LF & _
                                "should have returned an empty string per the doc." & @LF & _
                                @LF & _
                                "Instead, it returned the font face at the start of the selecton." & @LF & _
                                @LF & _
                                "Next, select what you'd like and press button to see what happens." & @LF & _
                                "That leads to issue #2, which is, after _GUICtrlRichEdit_GetFont" & @LF & _
                                "the selection is invisible, and it's difficult to make another" & @LF & _
                                "selection.  Before a selection can be made, click anywhere on the" & @LF & _
                                "text in the RichEdit box, then click the button.  Then you'll be" & @LF & _
                                "able to make another selection, and the issues repeat.  Try various" & @LF & _
                                "selections (right to left, one font through another, etc."
                GUICtrlSetData($lblMsg, $sMsg)
EndFunc   ;==>Example


Attachments (0)

Change History (2)

comment:1 Changed 10 years ago by water

  • Component changed from AutoIt to Standard UDFs

comment:2 Changed 10 years ago by Jpm

  • Milestone set to
  • Owner set to Jpm
  • Resolution set to Fixed
  • Status changed from new to closed

Fixed by revision [9091] in version:

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

as closed The owner will remain Jpm.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.