设置(第一)当前选择(或没有选择时的插入点所在段落)的制表位
#Include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetParaTabStops($hWnd, $sTabStops)
$hWnd | 控件句柄 |
$sTabStops | 由(;)分隔的字符串. 格式为: 制表位的绝对位置 (空间单位) 制表符类别 l - 左制表符 c - 居中制表符 r - 小数制表符 b - bar tab 圆点头标类型 . - 点头标 - - 短划头标 _ - 下划线头标 = - 重叠线头标 t - 粗线头标 空格 - 没有头标 |
成功: | 返回 True |
失败: | 返回 False设置@error |
@error: | 101 - $hWnd 参数值不是句柄 |
1021 - 制表位的绝对位置缺少或无效 | |
1022 - 制表符类别缺少或无效 | |
1023 - 制表符类别头标缺少或无效 | |
1024 - 尝试设置的制表位太多 | |
@extended 包含 $sTabStops 发生错误的标签号码(参考备注 1). |
在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