搜索插入点或定位点的选择文本
#Include <GuiRichEdit.au3>
_GUICtrlRichEdit_FindText($hWnd, $sText [, $fForward = True [, $fMatchCase = False [, $fWholeWord = False [, $iBehavior = 0]]]])
$hWnd | 控件句柄 |
$sText | 搜索的文本 |
$fForward | [可选参数] 搜索方向 (Win 95: 总是向前搜索) |
$fMatchCase | [可选参数] 是否区分大小写 默认 : 不区分大小写 |
$fWholeWord | [可选参数] 搜索完整单词 默认 : 部分或全部字 |
$iBehavior | [可选参数] 任何 BitOr 组合: $FR_MATCHALEFHAMZA, $FR_MATCHDIAC 与 $FR_MATCHKASHIDA 默认 : 0 |
成功: | 返回字符区间开始位置匹配的文本,否则返回 -1 | |
失败: | 返回 -1,设置@error: | |
@error: | 101 - $hWnd 参数值不是句柄 | |
102 - $sText = "" | ||
103 - $fForward 既不是 True, 也不是 False | ||
104 - $fMatchCase 既不是 True, 也不是 False | ||
105 - $fWholeWord 既不是 True, 也不是 False | ||
1061 - $iBehavior 不是一个数字 | ||
1062 - $iBehavior 无效 |
在MSDN中搜索
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $lblMsg, $hRichEdit
Main()
Func Main()
Local $hGui, $iMsg, $btnNext, $iStep = 0
$hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, 4) & ")", 320, 350, -1, -1)
$hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
$lblMsg = GUICtrlCreateLabel("", 10, 235, 300, 60)
$btnNext = GUICtrlCreateButton("Next", 270, 310, 40, 30)
GUISetState()
_GUICtrlRichEdit_AppendText($hRichEdit, @CR & "This is appended text.")
While True
$iMsg = GUIGetMsg()
Select
Case $iMsg = $GUI_EVENT_CLOSE
_GUICtrlRichEdit_Destroy($hRichEdit) ; 除非脚本崩溃才需要
;~ GUIDelete() ; 同样行
Exit
Case $iMsg = $btnNext
$iStep += 1
Switch $iStep
Case 1
_GUICtrlRichEdit_SetSel($hRichEdit, 8, 8)
Report("1.set starting position ")
Case 2
Report('2."appended" found just after inter-character position ' & _
_GUICtrlRichEdit_FindText($hRichEdit, "appended"))
GUICtrlSetState($btnNext, $GUI_DISABLE)
EndSwitch
EndSelect
WEnd
EndFunc ;==>Main
Func Report($sMsg)
GUICtrlSetData($lblMsg, $sMsg)
EndFunc ;==>Report