获取(第一)选中段落;或没有选择时的当前段落属性
#Include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetParaAttributes($hWnd)
$hWnd | 控件句柄 |
成功: | 返回由分号 ";" 分隔的字符串值. | |
值 1 至 10:此组包括: | ||
字符 1 到 3 - 代表属性 | ||
fpg - 强制这个/这些段落到新页面(初始关闭) | ||
hyp - 自动断字(最初的) | ||
kpt - 保持这个/这些段落在同一页面上(最初关闭) | ||
kpn - 保持这个/这些段落和下一段落同一页面上(最初关闭) | ||
pwo - 阻止短行与孤立行,避免这个/这些段落页面出现单一行(最初关闭) | ||
on a page (Initially off) | ||
r2l - 显示文本使用从右到左的阅读顺序(刚开始关闭 | ||
sbs - 显示段落并排(刚开始关闭) | ||
sln - 隐藏文档中的行号或带行号的片段(初始关闭) | ||
tbl - 段落为表格行(初始关闭) | ||
字符 4 - 状态: | ||
+ - 启用属性 | ||
- - 关闭属性 | ||
字符 11 - 范围: | ||
f - 第一个选中段落有这些属性 | ||
c - 当前段落有这些属性 | ||
失败: | 返回 "" ,设置@error: | |
@error: | 101 - $hWnd 参数值不是句柄 |
在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, "First paragraph")
Report("First paragraph: default attributes")
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_AppendText($hRichEdit, @CR & "Second paragraph")
_GUICtrlRichEdit_SetParaAttributes($hRichEdit, "-hyp")
Report("Second paragraph: hyphenation off")
Case 2
_GUICtrlRichEdit_SetSel($hRichEdit, 10, -1)
_GUICtrlRichEdit_SetParaAttributes($hRichEdit, "-hyp;+fpg;+kpn")
Report("Attributes of first paragraph in selection")
Case 3
; Stream all text to the Desktop so you can look at attributes in Word
_GUICtrlRichEdit_Deselect($hRichEdit)
_GUICtrlRichEdit_StreamToFile($hRichEdit, @DesktopDir & "\gcre.rtf")
GUICtrlSetState($btnNext, $GUI_DISABLE)
EndSwitch
EndSelect
WEnd
EndFunc ;==>Main
Func Report($sMsg)
$sMsg = $sMsg & @CR & @CR & "Get function returns " & @CR & _GUICtrlRichEdit_GetParaAttributes($hRichEdit)
GUICtrlSetData($lblMsg, $sMsg)
ControlFocus($hRichEdit, "", "")
EndFunc ;==>Report