返回选中文本的属性
#Include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetCharAttributes($hWnd)
$hWnd | 控件句柄 |
成功: | 返回一个 3 字符组成的字符串. | |
第一个和第二个字:: | ||
bo - 粗体 | ||
di - 禁用 - 字符带有阴影 [nd] | ||
em - 凸起 [nd] | ||
hi - 隐藏,即不显示 | ||
im - 印记 [nd] | ||
it - 斜体 | ||
li - 鼠标在带该属性的文本上时,发送 EN_LINK 消息 | ||
ou - 摘要 [nd] | ||
pr - 试图修改时发送 EN_PROTECT 消息 | ||
re - 标记为修订 [nd] | ||
sh - 阴影 [nd] | ||
sm - 小体大写字母 [nd] | ||
st - 删除 | ||
sb - 注脚 [nd] | ||
sp - 上标 [nd] | ||
un - 下划线 | ||
第三个字符:+ (译注:后面的文字不知何意,从运行结果看,不汉化也没什么影响:for on, ~ for mixed) | ||
失败: | 返回 "" ,设置@error: | |
@error: | 101 - $hWnd 参数值不是句柄 | |
-1 - 没有选中的文本 |
在MSDN中搜索
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Global $lblMsg, $hRichEdit
Main()
Func Main()
Local $hGui, $iMsg, $iCp1
$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)
GUISetState()
_GUICtrlRichEdit_AutoDetectURL($hRichEdit, True)
_GUICtrlRichEdit_AppendText($hRichEdit, @CR & "http://www.autoitscript.com")
$iCp1 = _GUICtrlRichEdit_GetFirstCharPosOnLine($hRichEdit, 2)
_GUICtrlRichEdit_SetSel($hRichEdit, $iCp1, $iCp1 + 3)
Report("Character attributes at start of line 2 are " & _
_GUICtrlRichEdit_GetCharAttributes($hRichEdit))
While True
$iMsg = GUIGetMsg()
Select
Case $iMsg = $GUI_EVENT_CLOSE
_GUICtrlRichEdit_Destroy($hRichEdit) ; 除非脚本崩溃才需要
;~ GUIDelete() ; 同样行
Exit
EndSelect
WEnd
EndFunc ;==>Main
Func Report($sMsg)
GUICtrlSetData($lblMsg, $sMsg)
EndFunc ;==>Report