CRichEditCtx.SaveDocmethod
Saves the document.
Syntax
FUNCTION SaveDoc (BYVAL pVar AS VARIANT PTR, BYVAL Flags AS LONG = tomRTF, BYVAL CodePage AS LONG = CP_ACP) AS HRESULT
Parameters
| Name | Description | |
|---|---|---|
pVar | The save target. This parameter is a VARIANT, which can be a file name, or NULL. See Remarks. | |
Flags | File creation, share, and conversion flags. For a list of possible values, see the tables below. | |
CodePage | The specified code page. Common values are CP_ACP (zero: system ANSI code page), 1200 (Unicode), and 1208 (UTF-8). |
Return value
The return value can be an HRESULT value that corresponds to a system error or COM error code, including one of the following values.
Description
Saves the document.
Any combination of these values may be used.
These values are mutually exclusive.
Remarks
To use the parameters that were specified for opening the file, use zero values for the parameters.
If pVar is null or missing, the file name given by this document's name is used. If both of these are missing or null, the method fails.
If pVar specifies a file name, that name should replace the current Name property. Similarly, the Flags and CodePage arguments can overrule those supplied in the OpenDoc method and define the values to use for files created with the NewDoc method.
Unicode plain-text files should be saved with the Unicode byte-order mark (&hFEFF) as the first character. This character should be removed when the file is read in; that is, it is only used for import/export to identify the plain text as Unicode and to identify the byte order of that text. Microsoft Notepad adopted this convention, which is now recommended by the Unicode standard.
Examples
pRichEdit->SaveDoc(BYVAL NULL) -- or -- pRichEdit->SaveDoc(BYVAL NULL, tomRTF)
pRichEdit->SaveDoc(BYVAL NULL, tomText)
pRichEdit->SaveDoc(BYVAL NULL, tomText, CP_UTF8)
pRichEdit->SaveDoc(BYVAL NULL, tomText, 1200)
DIM dv AS DVARIANT = AfxGetExePath & $"\Test02.rtf" pRichEdit->SaveDoc(dv, tomCreateAlways OR tomRTF)
DIM dv AS DVARIANT = AfxGetExePath & $"\Test02.txt" pRichEdit->SaveDoc(dv, tomCreateAlways OR tomText)
DIM dv AS DVARIANT = AfxGetExePath & $"\Test02.txt" pRichEdit->SaveDoc(dv, tomCreateAlways OR tomText, CP_UTF8)
DIM dv AS DVARIANT = AfxGetExePath & $"\Test02.txt" pRichEdit->SaveDoc(dv, tomCreateAlways OR tomText, 1200)
Overwrites the current document in RTF format: Overwrites the current document in text format: Overwrites the current document in utf-8 format: Overwrites the current document in unicode format: Saves the current document in RTF format: Saves the current document in text format: Saves the current document in utf-8 (with BOM): Saves the current document in unicode:
Reference
- Defined in AfxNova/CRichEditCtx.inc:4234
- Documented in Windows/WIndows Controls/RichEdit/CRichEditCtx Class.md
- Topic: CRichEditCtx Class