#include <GuiRichEdit.au3>
#include <GUIConstants.au3>
Global $hRichEdit
Main()
Func Main()
Local $hGui, $iMsg
$hGui = GUICreate("Rich Edit Example", 500, 550, -1, -1)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 480, 420, _
BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
GUISetState()
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
_GuiCtrlRichEdit_SetEventMask($hRichEdit, $ENM_LINK)
_GuiCtrlRichEdit_AutoDetectURL($hRichEdit, True)
_GuiCtrlRichEdit_AppendText($hRichEdit, @CR & "mailto:[email protected]?subject=oil_pump" & @CRLF )
While True
$iMsg = GUIGetMsg()
Select
Case $iMsg = $GUI_EVENT_CLOSE
Exit
EndSelect
WEnd
EndFunc ;==>Main
Func WM_NOTIFY($hWnd, $iMsg, $iWparam, $iLparam)
Local $hWndFrom, $iCode, $tNMHDR, $tEnLink, $cpMin, $cpMax, $tMsgFilter
$tNMHDR = DllStructCreate($tagNMHDR, $iLparam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hRichEdit
Select
Case $iCode = $EN_LINK
$tMsgFilter = DllStructCreate($tagEN_MSGFILTER, $iLparam)
If DllStructGetData($tMsgFilter, "msg") = $WM_LBUTTONUP Then
$tEnLink = DllStructCreate($tagENLINK, $iLparam)
$cpMin = DllStructGetData($tEnLink, "cpMin")
$cpMax = DllStructGetData($tEnLink, "cpMax")
_ShellExecuteEx(_GuiCtrlRichEdit_GetTextInRange($hRichEdit, $cpMin, $cpMax))
EndIf
EndSelect
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _ShellExecuteEx($sFileName, $sParameters = "", $sWorkingDir = "", $sVerb = "open", $iShowFlag = @SW_SHOWNORMAL)
Local $aRet = DllCall("Shell32.dll", "long", "ShellExecute", _
"hwnd", 0, "str", $sVerb, "str", $sFileName, "str", $sParameters, "str", $sWorkingDir, "int", $iShowFlag)
If @error Or $aRet[0] <= 32 Then Return SetError(1, 0, 0)
Return 1
EndFunc