Function Reference


_GUICtrlRichEdit_ChangeFontSize

Increment or decrement font size(s) of selected text

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_ChangeFontSize ( $hWnd, $iIncrement )

Parameters

$hWnd Handle to the control
$iIncrement Positive to increase, negative to decrease

Return Value

Succcess: True, Font sizes were changed.
Failure: False and may sets the @error flag to non-zero.
@error: 101 - $hWnd is not a handle
102 - $iIncrement is not a number
-1 - no text selected

Remarks

If there are several font sizes in the selected text, all are incremented/decremented.

For $iIncrement positive, font sizes are rounded up; for $iIncrement negative, they are rounded down.

Rich Edit first adds $iIncrement to the existing font size. It then rounds up (or down) as follows:
<= 12 points: 1 e.g. 7 + 1 => 8 points, 14 - 3 => 10 points
12.05 to 28 points: 20 + 2.25 => 24 points
28.05 to 80 points: rounded to next of 28, 36, 48, 72 or 80, e.g. 28 + 1 => 36 points, 80 - 1 => 72 points
> 80 points: 10, e.g. 80 + 1 => 90

Related

_GUICtrlRichEdit_SetFont

See Also

Search EM_SETFONTSIZE in MSDN Library.

Example

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

Global $g_idLblMsg, $g_hRichEdit

Example()

Func Example()
    Local $hGui, $iMsg, $idBtnDoIt
    $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)
    $idBtnDoIt = GUICtrlCreateButton("Do it", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_SetSel($g_hRichEdit, 0, -1) ; select all

    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 = $idBtnDoIt
                ChangeFontSize()
        EndSelect
    WEnd
EndFunc   ;==>Example

Func ChangeFontSize()
    Local $avArray, $iOld, $iNew
    $avArray = _GUICtrlRichEdit_GetFont($g_hRichEdit)
    $iOld = $avArray[0]
    _GUICtrlRichEdit_ChangeFontSize($g_hRichEdit, 2)
    $avArray = _GUICtrlRichEdit_GetFont($g_hRichEdit)
    $iNew = $avArray[0]
    Report("Was " & $iOld & " points; is now " & $iNew & " points")
EndFunc   ;==>ChangeFontSize

Func Report($sMsg)
    GUICtrlSetData($g_idLblMsg, $sMsg)
EndFunc   ;==>Report