Active ou désactive la détection automatique des URLs
#include <GuiRichEdit.au3>
_GUICtrlRichEdit_AutoDetectURL ( $hWnd, $bState )
$hWnd | Handle du contrôle |
$bState | True pour détecter les URLs dans le texte, False sinon |
Succès: | Retourne True. |
Échec: | Retourne False et définit @error <> 0. |
@error: | 101 - $hWnd n'est pas un handle 102 - $fState n'est ni True ni False 700 - Erreur interne, par exemple mémoire insuffisante |
Si la détection est activée, tout texte modifié est scanné pour rechercher le format d'une URL.
La fonction reconnaît les chaînes commençant par le texte suivant:
URLs: http:, file:, mailto:, ftp:, https:, gopher:, nntp:, prospero:, telnet:, news:, wais:.
Quand une URL est détectée, Windows définit l'attribut link pour tous les caractères de la chaîne URL, et met la chaîne en surbrillance.
Lorsque la détection automatique d'URL est active, et qu'une URL est détectée, Windows supprime l'attribut link de tous les caractères qui ne sont pas des URLs.
Pour que la notification arrive, appelez _GUICtrlRichEdit_SetEventMask() avec $ENM_LINK
Consultez EM_AUTOURLDETECT in MSDN Library. Search EN_LINK 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") Do Until GUIGetMsg() = $GUI_EVENT_CLOSE _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 signalez-le " & _ _GUICtrlRichEdit_GetTextInRange($g_hRichEdit, $iCpMin, $iCpMax)) EndIf EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY