Enables or disables automatic detection of URLS
#include <GuiRichEdit.au3>
_GUICtrlRichEdit_AutoDetectURL ( $hWnd, $bState )
$hWnd | Handle to the control |
$bState | True to detect URLs in text, False not to |
Success: | True. |
Failure: | False and sets the @error flag to non-zero. |
@error: | 101 - $hWnd is not a handle 102 - $bState is neither True nor False 700 - internal error, e.g. insufficient memory |
If enabled, any modified text is scanned for text that matches the format of a URL.
It recognizes strings starting with the following as:
URLs: http:, file:, mailto:, ftp:, https:, gopher:, nntp:, prospero:, telnet:, news:, wais:.
When a URL is detected, Windows sets the link attribute for all characters in the URL string, and highlights the string.
When automatic URL detection is on and a URL is detected, Windows removes the link attribute of all characters that are not URLs.
For notification to happen, call _GUICtrlRichEdit_SetEventMask() with $ENM_LINK
Search EM_AUTOURLDETECT in MSDN Library. Search EN_LINK in MSDN Library.
#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>
Global $g_hRichEdit
Example()
Func Example()
Local $hGui, $iMsg
$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))
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 True
$iMsg = GUIGetMsg()
Select
Case $iMsg = $GUI_EVENT_CLOSE
_GUICtrlRichEdit_Destroy($g_hRichEdit) ; needed unless script crashes
; GUIDelete() ; is OK too
Exit
EndSelect
WEnd
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")
Switch $hWndFrom
Case $g_hRichEdit
Select
Case $iCode = $EN_LINK
$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, "", "Invoke your web browser here and point it to " & _
_GUICtrlRichEdit_GetTextInRange($g_hRichEdit, $iCpMin, $iCpMax))
EndIf
EndSelect
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY