设置(第一)当前选择(或没有选择时的插入点所在段落)的编号方式
#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetParaNumbering($hWnd, $sStyle [, $iTextToNbrSpace = Default [, $fForceRoman=False]])
$hWnd | 控件句柄 |
$sStyle | 指定编号字符的样式与开始的数字: 例如: "." (加重号), "1)","(b)", "C.", "iv", "V)" 为第一选定段落显示的编号. 段落与编号的间距为最小值,除非使用 $iTextToNbrSpace 的指定值 特殊情况: "=" - 该段落前面有列表元素,为没有编号的段落 "" - 删除所选段落的编号 |
$iTextToNbrSpace | [可选参数] 编号的数字或符号与段落的间距 (空间单位) 默认 : 尾随空间数总是使用磅值大小(注:1 磅=1/72 英寸)大小 |
$fForceRoman | [可选参数] False - i, v, x ... 在 $sStyle 中是字母 i, v, x ... {默认) |
成功: | 返回 True |
失败: | 返回 False,设置@error |
@error: | 101 - $hWnd 参数值不是句柄 |
103 - $iTextToNbrSpace 不是正数 | |
104 - $fForceRoman 必须是 True 或 False |
在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")
_GUICtrlRichEdit_SetSel($hRichEdit, 0, 1)
Report("Para with default indent 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_SetParaNumbering($hRichEdit, ".")
Report("Added second paragraph")
Case 2
_GUICtrlRichEdit_SetSel($hRichEdit, 0, 2)
Report("Style of first paragraph in the selection")
Case 3
_GUICtrlRichEdit_SetSel($hRichEdit, 10, 26)
_GUICtrlRichEdit_SetParaNumbering($hRichEdit, "v) ", Default, True)
Report("Change settings of both paragraphs")
Case 4
_GUICtrlRichEdit_SetSel($hRichEdit, 10, 26)
_GUICtrlRichEdit_SetParaNumbering($hRichEdit, "2. ", Default, True)
Report("Changed settings for 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_GetParaNumbering($hRichEdit)
GUICtrlSetData($lblMsg, $sMsg)
ControlFocus($hRichEdit, "", "")
EndFunc ;==>Report