Augmente ou diminue les tailles de polices du texte sélectionné
#include <GuiRichEdit.au3>
_GUICtrlRichEdit_ChangeFontSize ( $hWnd, $iIncrement )
$hWnd | Handle du contrôle |
$iIncrement | Positif pour augmenter, négatif pour réduire |
Succès: | Retourne True, les tailles de police ont été modifiées. |
Échec: | Retourne False et @error<> 0. |
@error: | 101 - $hWnd n'est pas un handle 102 - $iIncrement n'est pas un nombre -1 - Aucun texte sélectionné |
S'il y a plusieurs tailles de police dans le texte sélectionné, toutes sont incrémentés/décrémentés.
Pour $iIncrement positif, les tailles de police sont arrondies au dessus; pour $iIncrement négatif, elles sont arrondies au dessous.
RichEdit ajoute premièrement $iIncrement à la taille de la police existante. Ensuite il arrondi au dessus(ou au dessous), comme il suit:
<= 12 points: 1 par exemple 7 + 1 => 8 points, 14-3 => 10 points
12.05 à 28 points: 20 + 2,25 => 24 points
28.05 à 80 points: arrondis au plus proche de 28, 36, 48, 72 ou 80, par exemple, 28 + 1 => 36 points, à 80 - 1 => 72 points
> 80 points: 10, par exemple 80 + 1 => 90
Consultez EM_SETFONTSIZE dans la librairie MSDN.
#include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <WindowsConstants.au3> Global $g_idLblMsg, $g_hRichEdit Example() Func Example() Local $hGui, $iMsg, $idBtnDoIt $hGui = GUICreate("Exemple (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1) $g_hRichEdit = _GUICtrlRichEdit_Create($hGui, "Ceci est un 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) ; Sélectionne tout Do $iMsg = GUIGetMsg() if $iMsg = $idBtnDoIt Then ChangeFontSize() EndIf Until $iMsg = $GUI_EVENT_CLOSE _GUICtrlRichEdit_Destroy($g_hRichEdit) ; Nécessaire sauf si le script se bloque ; GUIDelete(); est OK aussi 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("Etait " & $iOld & " points; est maintenant " & $iNew & " points") EndFunc ;==>ChangeFontSize Func Report($sMsg) GUICtrlSetData($g_idLblMsg, $sMsg) EndFunc ;==>Report