UDF > GUI > GuiRichEdit >


_GUICtrlRichEdit_Deselect

Enlève la sélection d'un texte, ne laissant aucune sélection

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

Paramètre

$hWnd Handle du contrôle

Valeur de retour

Succès: Retourne True.
Échec: Retourne False et définit @error <> 0.
@error: 101 - $hWnd n'est pas un handle

Remarque

Laisse le point d'insertion à la pointe de la sélection d'ancrage.

En relation

_GUICtrlRichEdit_GetSel, _GUICtrlRichEdit_IsTextSelected, _GUICtrlRichEdit_SetSel

Voir aussi

Consultez EM_SETSEL dans la librairie MSDN.

Exemple

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

Global $g_idLblMsg

Example()

Func Example()
    Local $hGui, $iMsg, $aiSel, $idBtnNext, $hRichEdit, $iStep = 0
    $hGui = GUICreate("Exemple (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1)
    $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)
    $idBtnNext = GUICtrlCreateButton("Suivant", 270, 310, 40, 30)
    GUISetState(@SW_SHOW)

    $iMsg = GUIGetMsg()
    While $iMsg <> $GUI_EVENT_CLOSE
        If $iMsg = $idBtnNext Then
            $iStep += 1
            Switch $iStep
                Case 1
                    _GUICtrlRichEdit_SetSel($hRichEdit, 5, 12)
                    $aiSel = _GUICtrlRichEdit_GetSel($hRichEdit)
                    Report("1.Du texte est sélectionné à partir de la position inter-caractères " & $aiSel[0] & " jusqu'à " & $aiSel[1])
                Case 2
                    _GUICtrlRichEdit_Deselect($hRichEdit)
                    $aiSel = _GUICtrlRichEdit_GetSel($hRichEdit)
                    If $aiSel[0] = $aiSel[1] Then Report("2.Aucun texte n'est sélectionné maintenant")
                    GUICtrlSetState($idBtnNext, $GUI_DISABLE)
            EndSwitch
        EndIf
        $iMsg = GUIGetMsg()
    WEnd

    _GUICtrlRichEdit_Destroy($hRichEdit) ; Nécessaire sauf si le script se bloque
    ; GUIDelete(); est OK aussi 
EndFunc   ;==>Example

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