Function Reference


_GUICtrlRichEdit_StreamToFile

Writes contents of a control to a file

#include <GuiRichEdit.au3>
_GUICtrlRichEdit_StreamToFile ( $hWnd, $sFileSpec [, $bIncludeCOM = True [, $iOpts = 0 [, $iCodePage = 0]]] )

Parameters

$hWnd Handle to the control
$sFileSpec file specification
$bIncludeCOM [optional] True (default):
    If writing to a .rtf file, includes any COM objects (space consuming)
    If writing to any other file, writes a text represntation of COM objects
False: Writes spaces instead of COM objects
$iOpts [optional] additional options: (default: 0)
    $SFF_PLAINRTF - write only rich text keywords common to all languages
    $SF_UNICODE - write Unicode
$iCodePage [optional] Generate UTF-8 and text using this code page
Default: do not

Return Value

Success: True
Failure: False and sets the @error flag to non-zero.
@error: 101 - $hWnd is not a handle
102 - Can't create $sFileSpec
1041 - $SFF_PLAINRTF is invalid for a text file
1042 - $opts: invalid option
1043 - $SF_UNICODE is only valid for a text file
700 - internal error

Remarks

If text is selected, writes only the selection, else writes all text in the control.

If the extension in $sFileSpec is .rtf, RTF is written, else text.

Related

_GUICtrlRichEdit_SetLimitOnText, _GUICtrlRichEdit_StreamFromFile, _GUICtrlRichEdit_StreamFromVar, _GUICtrlRichEdit_StreamToVar

See Also

Search EM_STREAMIN in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiRichEdit.au3>
#include <MsgBoxConstants.au3>
#include <WindowsConstants.au3>

Example()

Func Example()
    Local $hGui, $hRichEdit, $iMsg
    $hGui = GUICreate("Example (" & StringTrimRight(@ScriptName, StringLen(".exe")) & ")", 320, 350, -1, -1)
    $hRichEdit = _GUICtrlRichEdit_Create($hGui, "This is a test.", 10, 10, 300, 220, _
            BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL))
    GUISetState(@SW_SHOW)

    _GUICtrlRichEdit_AppendText($hRichEdit, "Para with default border settings")
    MsgBox($MB_SYSTEMMODAL, "", "The default paragraph border settings are " & _GUICtrlRichEdit_GetParaBorder($hRichEdit))

    _GUICtrlRichEdit_AppendText($hRichEdit, @CRLF & "Second paragraph")
    _GUICtrlRichEdit_SetParaBorder($hRichEdit, "o", 3, "mag", 0.25)
    MsgBox($MB_SYSTEMMODAL, "", "Border settings of second paragraph are " & _GUICtrlRichEdit_GetParaBorder($hRichEdit))

    _GUICtrlRichEdit_SetSel($hRichEdit, 10, -1)
    Sleep(1000)
    MsgBox($MB_SYSTEMMODAL, "", "Border settings of first paragraph in the selection are " & _GUICtrlRichEdit_GetParaBorder($hRichEdit))

    ; Change from outside border to left border
    _GUICtrlRichEdit_SetParaBorder($hRichEdit, "l")

    ; Stream all text to the Desktop so you can look at border settings in Word
    _GUICtrlRichEdit_Deselect($hRichEdit)
    _GUICtrlRichEdit_StreamToFile($hRichEdit, @DesktopDir & "\gcre.rtf")

    While True
        $iMsg = GUIGetMsg()
        Select
            Case $iMsg = $GUI_EVENT_CLOSE
                _GUICtrlRichEdit_Destroy($hRichEdit) ; needed unless script crashes
                ; GUIDelete()   ; is OK too
                Exit
        EndSelect
    WEnd
EndFunc   ;==>Example