Function Reference


_GUICtrlRichEdit_GetFont

Gets the font attributes of a selection or, if no selection, at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetFont ( $hWnd )

Parameters

$hWnd Handle to the control

Return Value

Success: an array containing values:
[0] - point size
    0 if sizes are mixed in selection
[1] - the name of the font
    "" if fonts are mixed in selection
[2] - the character set
    $ANSI_CHARSET - 0
    $BALTIC_CHARSET - 186
    $CHINESEBIG5_CHARSET - 136
    $EASTEUROPE_CHARSET - 238
    $GB2312_CHARSET - 134
    $GREEK_CHARSET - 161
    $HANGEUL_CHARSET - 129
    $HEBREW_CHARSET - 177
    $JOHAB_CHARSET - 130
    $MAC_CHARSET - 77
    $OEM_CHARSET - 255
    $RUSSIAN_CHARSET - 204
    $SHIFTJIS_CHARSET - 128
    $SYMBOL_CHARSET - 2
    $THAI_CHARSET - 222
    $TURKISH_CHARSET - 162
    $VIETNAMESE_CHARSET - 163
Those constants can be found in FontConstants.au3.
Failure: sets the @error flag to non-zero.
@error: 101 - $hWnd is not a handle

Related

_GUICtrlRichEdit_SetFont

See Also

Search EM_GETCHARFORMAT in MSDN Library. Search LOGFONT in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
        Local $hGui, $iMsg, $idBtnNext, $iStep = 0
        $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
        $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
                        BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
        $g_idLblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
        $idBtnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
        GUISetState(@SW_SHOW)

        While True
                $iMsg = GUIGetMsg()
                Select
                        Case $iMsg = $GUI_EVENT_CLOSE
                                _GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
                                ; GUIDelete()   ; is OK too
                                Exit
                        Case $iMsg = $idBtnNext
                                $iStep += 1
                                Switch $iStep
                                        Case 1
                                                Report("1. Initial")
                                        Case 2
                                                _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, 5)
                                                _GUICtrlRichEdit_SetFont($g_hRichEdit, 15, "Times New Roman")
                                                Report("2. Set Font")
                                                GUICtrlSetState($idBtnNext, $GUI_DISABLE)
                                EndSwitch
                EndSelect
        WEnd
EndFunc   ;==>Example

Func Report($sMsg)
        Local $aRet = _GUICtrlRichEdit_GetFont($g_hRichEdit)
        $sMsg = $sMsg & @CRLF & @CRLF & $aRet[1] & " " & $aRet[0] & " points"
        GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report