Obtient le texte d'une position inter-caractères à une autre
#include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetTextInRange ( $hWnd, $iStart, $iEnd )
$hWnd | Handle du contrôle |
$iStart | La position inter-caractères avant le texte |
$iEnd | La position inter-caractères après le texte Valeur spéciale: -1 représente la fin du texte |
Succès: | Retourne le texte. |
Échec: | Définit @error <> 0. |
@error: | 101 - $hWnd n'est pas un handle 102 - $iStart n'est ni positif ni zéro 1031 - $iEnd n'est ni positif, ni zéro, ni -1 1032 - $iStart > $iEnd et $iEnd <> -1 |
La position du premier caractère dans le contrôle est égal à 0.
_GUICtrlRichEdit_GetTextInLine
Consultez EM_GETTEXTRANGE dans la librairie MSDN.
#include <GUIConstantsEx.au3> #include <GuiRichEdit.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> Global $g_hRichEdit Example() Func Example() Local $hGui, $iMsg $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)) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") _GUICtrlRichEdit_SetEventMask($g_hRichEdit, $ENM_LINK) _GUICtrlRichEdit_AutoDetectURL($g_hRichEdit, True) _GUICtrlRichEdit_AppendText($g_hRichEdit, @CRLF & "http://www.autoitscript.com") While GUIGetMsg() <> $GUI_EVENT_CLOSE Wend _GUICtrlRichEdit_Destroy($g_hRichEdit) ; Nécessaire sauf si le script se bloque ; GUIDelete(); est OK aussi EndFunc ;==>Example Func WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndFrom, $iCode, $tNMHDR, $tEnLink, $iCpMin, $iCpMax, $tMsgFilter $tNMHDR = DllStructCreate($tagNMHDR, $lParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iCode = DllStructGetData($tNMHDR, "Code") If $hWndFrom = $g_hRichEdit Then If $iCode = $EN_LINK Then $tMsgFilter = DllStructCreate($tagMSGFILTER, $lParam) If DllStructGetData($tMsgFilter, "msg") = $WM_LBUTTONUP Then $tEnLink = DllStructCreate($tagENLINK, $lParam) $iCpMin = DllStructGetData($tEnLink, "cpMin") $iCpMax = DllStructGetData($tEnLink, "cpMax") MsgBox($MB_SYSTEMMODAL, "", "Invoquez votre navigateur Web ici et pointez-le sur " & _ _GUICtrlRichEdit_GetTextInRange($g_hRichEdit, $iCpMin, $iCpMax)) EndIf EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY