设置水平和垂直空间计算单位,供 _GUICtrlRichEdit 函数的参数使用
#include <GuiRichEdit.au3>
_GUICtrlRichEdit_SetSpaceUnit($sUnit)
$sUnit | "in", "cm", "mm", "pt" (磅), 或 "tw" (缇, 1/1440 英寸, 1/567 厘米) |
成功: | 返回 True |
失败: | 返回 False设置@error 为 1 |
#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, "Paragraph 1")
While True
$iMsg = GUIGetMsg()
Select
Case $iMsg = $GUI_EVENT_CLOSE
_GUICtrlRichEdit_Destroy($hRichEdit) ; 除非脚本崩溃才需要
;~ GUIDelete() ; 同样行
Exit
Case $iMsg = $btnNext
$iStep += 1
Switch $iStep
Case 1
Report("1. Initial setting")
Case 2
_GUICtrlRichEdit_SetSpaceUnit("cm")
Report("2. Setting is now")
GUICtrlSetState($btnNext, $GUI_DISABLE)
EndSwitch
EndSelect
WEnd
EndFunc ;==>Main
Func Report($sMsg)
$sMsg = $sMsg & @CR & @CR & _GUICtrlRichEdit_GetSpaceUnit()
GUICtrlSetData($lblMsg, $sMsg)
ControlFocus($hRichEdit, "", "")
EndFunc ;==>Report