Function Reference


_GUICtrlRichEdit_SetFont

Sets the font attributes of selected text or, if none selected, sets those of text inserted at the insertion point

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetFont ( $hWnd [, $iPoints = Default [, $sName = Default [, $iCharset = Default [, $iLcid = Default]]]] )

Parameters

$hWnd Handle to the control
$iPoints [optional] point size
$sName [optional] the name of the font face, e.g. "Courier" not "Courier Bold"
$iCharSet [optional] the character set - one of:
    $ANSI_CHARSET - 0
    $BALTIC_CHARSET - 186
    $CHINESEBIG5_CHARSET - 136
    $DEFAULT_CHARSET - 1
    $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.
$iLcid [optional] see http://www.microsoft.com/globaldev/reference/lcid-all.mspx

Return Value

Success: True.
Failure: False and sets the @error flag to non-zero.
@error: 101 - $hWnd is not a handle
102 - $iPoints is not a positive number
103 - $sName is not alphabetic
104 - $iCharSet is not a number
105 - $iLcid is not a number

Remarks

If a parameter is omitted (or is Default), the value is unchanged.

Related

_GUICtrlRichEdit_ChangeFontSize, _GUICtrlRichEdit_GetFont

See Also

Search EM_SETCHARFORMAT 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