获取(第一)选中段落;或者没有选择时的当前段落的制表位
#Include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetParaTabStops($hWnd)
$hWnd | 控件句柄 |
成功: | 返回由分号(;)分隔的字符串值: | |
值 1 - 制表符数量 | ||
值 2 到 | ||
+ 1 - 制表符描述: | ||
制表位的绝对位置 (空间单位) | ||
制表符类别 | ||
l - 左制表符 | ||
c - 居中制表符 | ||
r - 小数制表符 | ||
b - 分栏制表符(在 Word 中为一竖线) | ||
圆点头标类型 | ||
. - 点头标 | ||
- - 短划头标 | ||
_ - 下划线头标 | ||
= - 重叠线头标 | ||
t - 粗线头标 | ||
空格 - 没有头标 | ||
值 + 2 - 范围: | ||
a - 所有(或使用的)选定的段落进行这些设置 | ||
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_SetText($hRichEdit, "First paragraph")
Report("0. Para with default settings")
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_SetParaTabStops($hRichEdit, ".3l ;1c ;2.5r.")
Report("1. TabStops of second paragraph")
Case 2
_GUICtrlRichEdit_SetSel($hRichEdit, 0, 2)
Report("2. Tabstops of first paragraph")
Case 3
_GUICtrlRichEdit_SetSel($hRichEdit, 10, 26)
Report("Tabstops of first paragraph in selection")
Case 4
_GUICtrlRichEdit_SetParaTabStops($hRichEdit, "2.3r=")
Report("3. Change tabstops of both paragraphs")
Case 5
; 把所有的文本流保存到桌面,这样您可以在 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_GetParaTabStops($hRichEdit)
GUICtrlSetData($lblMsg, $sMsg)
ControlFocus($hRichEdit, "", "")
EndFunc ;==>Report