ILLBeBack Posted September 26, 2013 Share Posted September 26, 2013 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 at http://www.autoitscript.com/forum/topic/154905-selection-goes-invisible-after-guictrlrichedit-getfont/ expandcollapse popup#include <GuiRichEdit.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $lblMsg, $hRichEdit Example() 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, _ BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) $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) GUISetState() _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() Select Case $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes Exit 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) EndSelect WEnd EndFunc ;==>Example Exit Anyone have any thoughts? Should I report this a a bug? Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now