获取第一个选定段落;或者没有选择时的当前段落的边框缩进设置
#Include <GuiRichEdit.au3>
_GUICtrlRichEdit_GetParaIndents($hWnd)
$hWnd | 控件句柄 |
成功: | 返回设置 - 由分号(:) 分隔的字符串值 : | |
值 1 - 左 - 段落的左边缩进 (在第一行) (空间单位) | ||
值 2 - 右 - 段落的右侧缩进 (空间单位) | ||
值 3 - 第一线 - 第一行的缩进相对于其它行(空间单位) | ||
值 4 - 范围: | ||
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("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")
Report("Added second paragraph")
Case 2
_GUICtrlRichEdit_SetParaIndents($hRichEdit, 0.25, .1)
Report("Changed indent settings of second paragraph")
Case 3
_GUICtrlRichEdit_SetSel($hRichEdit, 10, 26)
_GUICtrlRichEdit_SetParaIndents($hRichEdit, Default, 0, .2)
Report("Change settings of both paragraphs")
Case 4
; Stream all text to the Desktop so you can look at Indents settings 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_GetParaIndents($hRichEdit)
GUICtrlSetData($lblMsg, $sMsg)
ControlFocus($hRichEdit, "", "")
EndFunc ;==>Report