控件的内容写入到文件
#Include <GuiRichEdit.au3>
_GUICtrlRichEdit_StreamToFile($hWnd, $sFilespec [, $fIncludeCOM=True [, $iOpts=0 [, $iCodePage = 0]]])
$hWnd | 控件句柄 |
$sFileSpec | 文件说明 |
$fIncludeCOM | [可选参数] True (default): 如果写到 .rtf 文件,包括任何 COM 对象(消耗空间) 如果写到任何其它文件, 以文本表达代替 COM 对象写入 False: 写入空格代替 COM 对象 |
$iOpts | [可选参数] 其他选项: (默认 : 0) $SFF_PLAINTRTF - 只写入对所有语言普遍适用的关键字 $SF_UNICODE - 写入 Unicode |
$iCodePage | [可选参数] 生成 UTF-8 和文字使用的代码页 默认 : 没有 |
成功: | 返回 True | |
失败: | 返回 False,设置@error: | |
@error: | 101 - $hWnd 参数值不是句柄 | |
102 - 不能创建 $sFilespec | ||
1041 - $SFF_PLAINRTF 是无效的文本文件 | ||
1042 - $opts:是无效的选项 | ||
1043 - $SF_UNICODE 仅对文本文件有效 | ||
700 - 内部错误 |
在MSDN中搜索
#include <GuiRichEdit.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Main()
Func Main()
Local $hGui, $hRichEdit, $iMsg
$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))
GUISetState()
_GUICtrlRichEdit_AppendText($hRichEdit, "Para with default border settings")
MsgBox(4096, "", "The default paragraph border settings are " & _GUICtrlRichEdit_GetParaBorder($hRichEdit))
_GUICtrlRichEdit_AppendText($hRichEdit, @CR & "Second paragraph")
_GUICtrlRichEdit_SetParaBorder($hRichEdit, "o", 3, "mag", 0.25)
MsgBox(4096, "", "Border settings of second paragraph are " & _GUICtrlRichEdit_GetParaBorder($hRichEdit))
_GUICtrlRichEdit_SetSel($hRichEdit, 10, -1)
Sleep(1000)
MsgBox(4096, "", "Border settings of first paragraph in the selection are " & _GUICtrlRichEdit_GetParaBorder($hRichEdit))
; Change from outside border to left border
_GUICtrlRichEdit_SetParaBorder($hRichEdit, "l")
; 把所有的文本流保存到桌面,这样您可以在 Word 中查看边框设置.
_GUICtrlRichEdit_Deselect($hRichEdit)
_GUICtrlRichEdit_StreamToFile($hRichEdit, @DesktopDir & "\gcre.rtf")
While True
$iMsg = GUIGetMsg()
Select
Case $iMsg = $GUI_EVENT_CLOSE
_GUICtrlRichEdit_Destroy($hRichEdit) ; 除非脚本崩溃才需要
;~ GUIDelete() ; 同样行
Exit
EndSelect
WEnd
EndFunc ;==>Main