Help Center
Help CenterAfxNovaWindows

CRichEditCtx Class

Members (322)

AfxCRichEditCtxPtrOverloaded function that retrieves a pointer to the `CRichEditCtx`class from the handle of the rich edit control or from the handle of its parent window and the control's identifier.ActiveStoryGets/sets the active story.AddCRAddCRLFAddLFAddLF/AddCR/AddCRLFInserts a line feed, a carriage return or a carriage return and line feed at the cursor position or at the end of the text.AppendDocFileAppends the contents of the specified RTF file.AttachMsgFilterAttaches a new message filter to the edit instance.AutoCorrectProcGets/sets a pointer to the application-defined **AutoCorrectProc** callback function.AutoUrlDetectGets/sets whether the auto URL detection is turned on in the rich edit control.BeginEditCollectionTurns on edit collection (also called *undo grouping*).BidiOptionsGets/sets the current state of the bidirectional options in the rich edit control.CallAutocorrectProcCalls the autocorrect callback function that is stored by the (SET) **AutocorrectProc** property, provided that the text preceding the insertion point is a candidate for autocorrection.CanPasteDetermines whether a rich edit control can paste a specified clipboard format.CanRedoDetermines whether there are any actions in the control redo queue.CanUndoDetermines whether there are any actions in an edit control's undo queue.CaretPosGets/sets the caret position.CaretTypeGets/sets the caret type.CharFormatGets/sets the current character formatting in a rich edit control.CheckTextLimitChecks whether the number of characters to be added would exceed the maximum text limit.CONSTRUCTORCalled when a class variable is created.CTFModeBiasGets/sets the Text Services Framework mode bias values for a Microsoft Rich Edit control.CTFOpenStatusGets/sets if the Text Services Framework (TSF) keyboard is open or closed.DefaultTabStopGets/sets the default tab width.DESTRUCTORCalled automatically when a class variable goes out of scope or is destroyed.DisableAutoUrlDetectDisableWordWrapDisplayBandDisplays a portion of the contents of a rich edit control, as previously formatted for a device using the EM_FORMATRANGE message.DocNameGets the file name of this document.DocumentFontGets/sets a font object that provides the default character format information for this instance of the Text Object Model (TOM) engine.DocumentParaGets/sets an object that provides the default paragraph format information for this instance of the Text Object Model (TOM) engine.EastAsianFlagsGets the East Asian flags.EditStyleGets/sets the current edit style flags.EditStyleExGets/sets the extended edit style flags.EffectColorGets/sets the color used for special text attributes.EllipsisModeGets/sets the current ellipsis mode.EllipsisStateGets the current ellipsis state.EmptyUndoBufferResets the undo flag of a rich edit control. The undo flag is set whenever an operation within the rich edit control can be undone.EnableAdvancedTypographyEnables advanced typography.EnableAutoUrlDetectEnableWordWrapEndEditCollectionTurns off edit collection (also called *undo grouping*).EventMaskGets/sets the event mask for a rich edit control.ExGetSelRetrieves the starting and ending character positions of the selection in a rich edit control.ExLimitTextSets an upper limit to the amount of text the user can type or paste into a rich edit control.ExLineFromCharDetermines which line contains the specified character in a rich edit control.ExSetSelSelects a range of characters and/or Component Object Model (COM) objects in a Microsoft Rich Edit control.FindTextFinds text within a rich edit control.FindTextExFinds text within a rich edit control.FindWordBreakFinds the next word break before or after the specified character position or retrieves information about the character at that position.FirstVisibleLineGets the zero-based index of the uppermost visible line in a rich edit control.FormatRangeFormats a range of text in a rich edit control for a specific device.FreezeIncrements the freeze count.FUNCTIONGetActiveStoryGetAutoCorrectProcGetAutoUrlDetectGetBidiOptionsGetCallManagerGets the call manager.GetCaretPosGetCaretTypeGetCharFormatGetCharFromPosGets information about the character closest to a specified point in the client area of an edit control.GetClientRectRetrieves the client rectangle of the rich edit control.GetCTFModeBiasGetCTFOpenStatusGetDefaultCharFormatGetDefaultTabStopGetDisplaysGets the displays collection for this Text Object Model (TOM) engine instance.GetDocumentFontGetDocumentInterfaceRetrieves a pointer to the ITextDocument2 interface.GetDocumentParaGetEastAsianFlagsGetEditStyleGetEditStyleExGetEffectColorGetEllipsisModeGetEllipsisStateGetErrorInfoReturns a localized description of the last result code.GetEventMaskGetFirstVisibleLineGetGeneratorGets the name of the Text Object Model (TOM) engine.GetHyphenateInfoGetIMEColorRetrieves the Input Method Editor (IME) composition color.GetIMECompModeGets the current IME mode for a rich edit control.GetIMECompTextGets the Input Method Editor (IME) composition text.GetIMEModeBiasGetIMEOptionsGetIMEPropertyGets the property and capabilities of the Input Method Editor (IME) associated with the current input locale.GetImmContextGets the Input Method Manager (IMM) input context from the Text Object Model (TOM) host.GetLangOptionsGetLastResultReturns the last result code.GetLimitTextGets the current text limit for a rich edit control.GetLineCopies a line of text from a rich edit control.GetLineCountGets the number of lines in a multiline rich edit control.GetMainStoryGetMathPropertiesGetModifyGetNewStoryGetNotificationModeGetOleInterfaceRetrieves an IRichEditOle object that a client can use to access a rich edit control's Component Object Model (COM) functionality.GetOptionsGetPageRotateGetParaFormatGetPasswordCharGetPreferredFontRetrieves the preferred font for a particular character repertoire and character position.GetPropertyGets the value of a property.GetPunctuationGetRawTextGets the raw text exactly as it appears in memory.GetRawTextLengthGets the length of the raw textGetRectGetRedoNameGetRtfRetrieves formatted text from a rich edit control.GetSavedGetScalingRatioGetScrollPosGetSelGets the starting and ending character positions of the current selection in a rich edit control.GetSelectionCharFormatGetSelTextRetrieves the currently selected text in a rich edit control.GetStoryRetrieves the story that corresponds to a particular index.GetStoryCountGetStoryRangesGets the story collection object used to enumerate the stories in a document.GetStoryRanges2Gets an object for enumerating the stories in a document.GetStoryTypeGetStringsGets a collection of rich-text strings.GetTableParamsRetrieves the table parameters for a table row and the cell parameters for the specified number of cells.GetTextGetTextColorGetTextExGets all of the text from the rich edit control in any particular code base you want.GetTextFontNameGetTextFromFileGets text from the specified file.GetTextHeightGetTextLengthGetTextLengthExGetTextModeGetTextOffsetGetTextRangeRetrieves a specified range of characters from a rich edit control.GetThumbGets the position of the scroll box (thumb) in the vertical scroll bar of a multiline rich edit control.GetTouchOptionsGetTypographyOptionsGetUndoNameGetWindowGets the handle of the window that the Text Object Model (TOM) engine is using to display output.GetWordBreakProcGetWordBreakProcExGetWordCharFormatGetWordWrapModeGetZoomGets the current zoom ratio, which is always between 1/64 and 64.HideSelectionHides or shows the selection in a rich edit control.hRichEditReturns the handle of the rich edit control.HyphenateInfoGets/sets information about hyphenation for a Microsoft Rich Edit control.IMEModeBiasGets/sets the Input Method Editor (IME) mode bias for a Microsoft Rich Edit control.IMEOptionsGets/sets the current Input Method Editor (IME) options. This message is available only in Asian-language versions of the operating system.InsertDocFileInserts the contents of the specified RTF file.InsertImageReplaces the selection with a blob that displays an image.InsertObjectInserts an image or a Ole object in the rich edit control.InsertTableInserts one or more identical table rows with empty cells.InsertTextInserts text at the specified location.IsIMEDetermines if current input locale is an East Asian locale.IsModifiedIsTextBoldChecks if the selected text or the word under the cursor is bolded.IsTextItalicChecks if the selected text or word under the cursor is italicised.IsTextStrikeOutChecks if the selected text or word under the cursor is striked out.IsTextUnderlineChecks if the selected text or word under the cursor is underlined.LangOptionsGets/sets a rich edit control's option settings for Input Method Editor (IME) and Asian language support.LeftMarginLimitTextGets/sets the current text limit for a rich edit control.LineFromCharGets the index of the line that contains the specified character index in a multiline rich edit control.LineIndexGets the character index of the first character of a specified line in a multiline rich edit control.LineLengthRetrieves the length, in characters, of a line in a rich edit control.LineScrollScrolls the text in a multiline rich edit control.LoadRtfFromFileLoadRtfFromResourceLoads a rich text resource file into a rich edit control.MainStoryGets the main story.MarginsSets the width of the specified margin.MathPropertiesGets the math properties for the document.ModifyGets/sets the state of a rich edit control's modification flag. The flag indicates whether the contents of the rich edit control have been modified.NewDocOpens a new document.NewStoryNot implemented. Gets a new story.NotificationModeGets/sets the notification mode.NotifyNotifies the Text Object Model (TOM) engine client of particular Input Method Editor (IME) events.OpenDocOpens a new document.OptionsGets/sets the options for a rich edit control.PageRotateDeprecated. Gets/sets the text layout for a Microsoft Rich Edit control.ParaFormatGets/sets the paragraph formatting of the current selection in a rich edit control.PasswordCharGets/sets the password character that a rich edit control displays when the user enters text.PasteSpecialPastes a specific clipboard format in a rich edit control.PosFromCharRetrieves the client area coordinates of a specified character in a rich edit control.PunctuationGets/sets the current punctuation characters for the rich edit control.RangeRetrieves a text range object for a specified range of content in the active story of the document.RangeFromPointRetrieves a range for the content at or nearest to the specified point on the screen.ReconversionInvokes the Input Method Editor (IME) reconversion dialog box.RectGets/sets the formatting rectangle of a rich edit control.RectNPSets the formatting rectangle of a multiline rich edit control.RedoRedoes the next action in the control's redo queue.RedoNameRetrieves the type of the next action, if any, in the control's redo queue.ReleaseCallManagerReleases the call manager.ReleaseImmContextReleases an Input Method Manager (IMM) input context.ReplaceSelReplaces the current selection in a rich edit control with the specified text.ReplaceTextReplaces text from the starting to ending position with the specified text.RequestResizeForces a rich edit control to send an **EN_REQUESTRESIZE** notification message to its parent window.RestoreTargetDeviceSets the target device to the device context of the rich edit control.ResumeUndoRightMarginSavedGets/sets the Saved property.SaveDocSaves the document.SaveRawTextSaves the raw contents of the rich edit control to a file.SaveRtfSaves the contents of the rich edit control to a file in rtf format.SaveRtfNoObjsSaves the contents of the rich edit control to a file in rtf format with spaces in place of COM objects.SaveSelRtfSaves selection of the rich edit control to a file in rtf format.SaveSelTextSaves selection of the rich edit control in text format.SaveTextSaves the contents of the rich edit control in text format.ScalingRatioGets/sets the scaling ratio.ScrollScrolls the text vertically in a multiline rich edit control.ScrollCaretScrolls the caret into view in a rich edit control.ScrollPosGets/sets the current scroll position of the edit control.SelectionGets the active selection.Selection2Gets the active selection.SelectionTypeDetermines the selection type for a rich edit control.SetActiveStorySetAutoCorrectProcSetAutoUrlDetectSetBidiOptionsSetBkgndColorSets the background color for a rich edit control.SetCaretPosSetCaretTypeSetCharFormatSetCTFModeBiasSetCTFOpenStatusSetDefaultCharFormatSetDefaultTabStopSetDocumentFontSetDocumentParaSetEditStyleSetEditStyleExSetEffectColorSetEllipsisModeSetEventMaskSetFontSets the font used by a rich edit control.SetFontSizeSets the font size for the selected text.SetHyphenateInfoSetIMEColorSets the Input Method Editor (IME) composition color.SetIMEInProgressSets the state of the Input Method Editor (IME) in-progress flag.SetIMEModeBiasSetIMEOptionsSetLangOptionsSetLeftMarginSetLimitTextSets the current text limit for a rich edit control.SetMarginsSetMathPropertiesSetModifySetNotificationModeSetOleCallbackGives a rich edit control an **IRichEditOleCallback** object that the control uses to get OLE-related resources and information from the client.SetOptionsSetPageRotateSetPaletteChanges the palette that a rich edit control uses for its display window.SetParaFormatSetPasswordCharSetPropertySets the value of a property.SetPunctuationSetReadOnlySets or removes the read-only style (ES_READONLY) of a rich edit control.SetRectSetRectNPSetResultSets the last result code.SetRightMarginSetSavedSetScalingRatioSetScrollPosSetSelSelects a range of characters in a rich edit control.SetSelectionCharFormatSetStoryTypeSetTableParamsChanges the parameters of rows in a table.SetTabStopsSets the tab stops in a multiline rich edit control.SetTargetDeviceSets the target device and line width used for WYSIWYG formatting in a rich edit control.SetTextSetTextBoldSets the attribute of selected text or word to bold.SetTextColorSetTextExCombines the functionality of WM_SETTEXT and EM_REPLACESEL and adds the ability to set text using a code page and to use either Rich Text Format (RTF) rich text or plain text.SetTextFontNameSetTextHeightSetTextItalicSets the attribute of selected text or word to italic.SetTextModeSetTextOffsetSetTextStrikeOutSets the attribute of selected text or word to strike out.SetTextUderlineSetTextUnderlineSets the attribute of selected text or word to underline.SetTouchOptionsSetTypographyOptionsSetUIANameSets the maximum number of actions that can stored in the undo queue.SetUndoLimitSets the maximum number of actions that can stored in the undo queue.SetWordBreakProcSetWordBreakProcExSetWordCharFormatSetWordWrapModeSetWysiwygPrintSets the target printer device and line width used for "what you see is what you get" (WYSIWYG) formatting in a rich edit control.SetZoomSets the zoom ratio anywhere between 1/64 and 64.ShowScrollBarShows or hides one of the scroll bars in the Text Host window.StopGroupTypingStops the control from collecting additional typing actions into the current undo action.StoryCountGets the number of stories in the document.StoryTypeGets/sets the story type.StreamInReplaces the contents of a rich edit control with a stream of data provided by an application defined EditStreamCallback callback function.StreamOutCauses a rich edit control to pass its contents to an application defined EditStreamCallback callback function.SuspendUndoSysBeepGenerates a system beep.TextGets/sets the text from a rich edit control.TextColorGets/sets the text color of the selected text or the word under the cursor.TextFontNameGets/sets the font name of the selected text or the word under the cursor.TextHeightGets/sets the text height of the selected text or the word under the cursor.TextLengthRetrieves the length of all text in a rich edit control.TextLengthExCalculates text length in various ways. It is usually called before creating a buffer to receive the text from the control.TextModeGets/sets the current text mode and undo level of a rich edit control.TextOffsetGets/sets the text offset of the selected text or the word under the cursor.TouchOptionsGets/sets the touch options that are associated with a rich edit control.TypographyOptionsGets/sets the current state of the typography options of a rich edit control.UndoThis message undoes the last edit control operation in the control's undo queue.UndoNameRetrieves the type of the next undo action, if any.UnfreezeDecrements the freeze count.UpdateUpdates the selection and caret.UpdateWindowNotifies the client that the view has changed and the client should update the view if the Text Object Model (TOM) engine is in-place active.WordBreakProcGets/sets the address of the currently registered word-break procedure.WordBreakProcExWordWrapEnables/disables word wrap.WordWrapModeSets the word-wrapping and word-breaking options for the rich edit control.

Documentation

CRichEditCtx Class

Provides the functionality of the rich edit control.

A "rich edit control" is a window in which the user can enter and edit text. The text can be assigned character and paragraph formatting, and can include embedded OLE objects. Rich edit controls provide a programming interface for formatting text. However, an application must implement any user interface components necessary to make formatting operations available to the user.

NameDescription
CONSTRUCTORCalled when a class variable is created.
DESTRUCTORCalled automatically when a class variable goes out of scope or is destroyed.
hRichEditReturns the handle of the rich edit control.
ScalingRatioGets/sets the scaling ratio.
SetWysiwygPrintSets the target printer device and line width used for "what you see is what you get" (WYSIWYG) formatting in a rich edit control.
RestoreTargetDeviceSets the target device to the device context of the rich edit control.
AfxCRichEditCtxPtrOverloaded function that retrieves a pointer to the CRichEditCtxclass from the handle of the rich edit control or from the handle of its parent window and the control's identifier.

Methods inherited from CTextObjectBase

NameDescription
GetLastResultReturns the last result code.
SetResultSets the last result code.
GetErrorInfoReturns a localized description of the last result code.

CRichEditCtx Properties

NameDescription
AutoCorrectProcGets/sets a pointer to the application-defined AutoCorrectProc callback function.
AutoUrlDetectGets/sets whether the auto URL detection is turned on in the rich edit control.
BidiOptionsGets/sets the current state of the bidirectional options in the rich edit control.
CaretPosGets/sets the caret position.
CharFormatGets/sets the current character formatting in a rich edit control.
CTFModeBiasGets/sets the Text Services Framework mode bias values for a Microsoft Rich Edit control.
CTFOpenStatusGets/sets if the Text Services Framework (TSF) keyboard is open or closed.
EditStyleGets/sets the current edit style flags.
EditStyleExGets/sets the extended edit style flags.
EllipsisModeGets/sets the current ellipsis mode.
EllipsisStateGets the current ellipsis state.
EventMaskGets/sets the event mask for a rich edit control.
FirstVisibleLineGets the zero-based index of the uppermost visible line in a rich edit control.
HyphenateInfoGets/sets information about hyphenation for a Microsoft Rich Edit control.
IMEModeBiasGets/sets the Input Method Editor (IME) mode bias for a Microsoft Rich Edit control.
IMEOptionsGets/sets the current Input Method Editor (IME) options. This message is available only in Asian-language versions of the operating system.
LangOptionsGets/sets a rich edit control's option settings for Input Method Editor (IME) and Asian language support.
LimitTextGets/sets the current text limit for a rich edit control.
MarginsSets the width of the specified margin.
ModifyGets/sets the state of a rich edit control's modification flag. The flag indicates whether the contents of the rich edit control have been modified.
OptionsGets/sets the options for a rich edit control.
PageRotateDeprecated. Gets/sets the text layout for a Microsoft Rich Edit control.
ParaFormatGets/sets the paragraph formatting of the current selection in a rich edit control.
PasswordCharGets/sets the password character that a rich edit control displays when the user enters text.
PunctuationGets/sets the current punctuation characters for the rich edit control.
RectGets/sets the formatting rectangle of a rich edit control.
RectNPSets the formatting rectangle of a multiline rich edit control.
RedoNameRetrieves the type of the next action, if any, in the control's redo queue.
ScrollPosGets/sets the current scroll position of the edit control.
StoryTypeGets/sets the story type.
TextGets/sets the text from a rich edit control.
TextColorGets/sets the text color of the selected text or the word under the cursor.
TextFontNameGets/sets the font name of the selected text or the word under the cursor.
TextHeightGets/sets the text height of the selected text or the word under the cursor.
TextLengthRetrieves the length of all text in a rich edit control.
TextLengthExCalculates text length in various ways. It is usually called before creating a buffer to receive the text from the control.
TextModeGets/sets the current text mode and undo level of a rich edit control.
TextOffsetGets/sets the text offset of the selected text or the word under the cursor.
TouchOptionsGets/sets the touch options that are associated with a rich edit control.
TypographyOptionsGets/sets the current state of the typography options of a rich edit control.
EnableAdvancedTypographyEnables advanced typography.
UndoNameRetrieves the type of the next undo action, if any.
WordBreakProcGets/sets the address of the currently registered word-break procedure.
WordWrapEnables/disables word wrap.
WordWrapModeSets the word-wrapping and word-breaking options for the rich edit control.

CRichEditCtx Methods

NameDescription
AddLF/AddCR/AddCRLFInserts a line feed, a carriage return or a carriage return and line feed at the cursor position or at the end of the text.
CallAutocorrectProcCalls the autocorrect callback function that is stored by the (SET) AutocorrectProc property, provided that the text preceding the insertion point is a candidate for autocorrection.
CanPasteDetermines whether a rich edit control can paste a specified clipboard format.
CanRedoDetermines whether there are any actions in the control redo queue.
CanUndoDetermines whether there are any actions in an edit control's undo queue.
DisplayBandDisplays a portion of the contents of a rich edit control, as previously formatted for a device using the EM_FORMATRANGE message.
EmptyUndoBufferResets the undo flag of a rich edit control. The undo flag is set whenever an operation within the rich edit control can be undone.
ExGetSelRetrieves the starting and ending character positions of the selection in a rich edit control.
ExLimitTextSets an upper limit to the amount of text the user can type or paste into a rich edit control.
ExLineFromCharDetermines which line contains the specified character in a rich edit control.
ExSetSelSelects a range of characters and/or Component Object Model (COM) objects in a Microsoft Rich Edit control.
FindTextFinds text within a rich edit control.
FindTextExFinds text within a rich edit control.
FindWordBreakFinds the next word break before or after the specified character position or retrieves information about the character at that position.
FormatRangeFormats a range of text in a rich edit control for a specific device.
GetCharFromPosGets information about the character closest to a specified point in the client area of an edit control.
GetDocumentInterfaceRetrieves a pointer to the ITextDocument2 interface.
GetIMEColorRetrieves the Input Method Editor (IME) composition color.
GetIMECompModeGets the current IME mode for a rich edit control.
GetIMECompTextGets the Input Method Editor (IME) composition text.
GetIMEPropertyGets the property and capabilities of the Input Method Editor (IME) associated with the current input locale.
GetLimitTextGets the current text limit for a rich edit control.
GetLineCopies a line of text from a rich edit control.
GetLineCountGets the number of lines in a multiline rich edit control.
GetOleInterfaceRetrieves an IRichEditOle object that a client can use to access a rich edit control's Component Object Model (COM) functionality.
GetRedoNameRetrieves the type of the next action, if any, in the control's redo queue.
GetRtfRetrieves formatted text from a rich edit control.
GetRawTextGets the raw text exactly as it appears in memory.
GetRawTextLengthGets the length of the raw text
GetSelGets the starting and ending character positions of the current selection in a rich edit control.
GetSelTextRetrieves the currently selected text in a rich edit control.
GetTableParamsRetrieves the table parameters for a table row and the cell parameters for the specified number of cells.
GetTextExGets all of the text from the rich edit control in any particular code base you want.
GetTextRangeRetrieves a specified range of characters from a rich edit control.
GetThumbGets the position of the scroll box (thumb) in the vertical scroll bar of a multiline rich edit control.
GetZoomGets the current zoom ratio, which is always between 1/64 and 64.
HideSelectionHides or shows the selection in a rich edit control.
InsertImageReplaces the selection with a blob that displays an image.
InsertObjectInserts an image or a Ole object in the rich edit control.
InsertTableInserts one or more identical table rows with empty cells.
InsertTextInserts text at the specified location.
IsIMEDetermines if current input locale is an East Asian locale.
IsTextBoldChecks if the selected text or the word under the cursor is bolded.
IsTextItalicChecks if the selected text or word under the cursor is italicised.
IsTextStrikeOutChecks if the selected text or word under the cursor is striked out.
IsTextUnderlineChecks if the selected text or word under the cursor is underlined.
LineFromCharGets the index of the line that contains the specified character index in a multiline rich edit control.
LineIndexGets the character index of the first character of a specified line in a multiline rich edit control.
LineLengthRetrieves the length, in characters, of a line in a rich edit control.
LineScrollScrolls the text in a multiline rich edit control.
PasteSpecialPastes a specific clipboard format in a rich edit control.
PosFromCharRetrieves the client area coordinates of a specified character in a rich edit control.
RedoRedoes the next action in the control's redo queue.
ReplaceSelReplaces the current selection in a rich edit control with the specified text.
ReplaceTextReplaces text from the starting to ending position with the specified text.
RequestResizeForces a rich edit control to send an EN_REQUESTRESIZE notification message to its parent window.
ReconversionInvokes the Input Method Editor (IME) reconversion dialog box.
ScrollScrolls the text vertically in a multiline rich edit control.
ScrollCaretScrolls the caret into view in a rich edit control.
SelectionTypeDetermines the selection type for a rich edit control.
SetBkgndColorSets the background color for a rich edit control.
SetFontSets the font used by a rich edit control.
SetFontSizeSets the font size for the selected text.
SetIMEColorSets the Input Method Editor (IME) composition color.
SetLimitTextSets the current text limit for a rich edit control.
SetOleCallbackGives a rich edit control an IRichEditOleCallback object that the control uses to get OLE-related resources and information from the client.
SetOptionsSets the options for a rich edit control.
SetPaletteChanges the palette that a rich edit control uses for its display window.
SetReadOnlySets or removes the read-only style (ES_READONLY) of a rich edit control.
SetRectNPSets the formatting rectangle of a rich edit control.
SetSelSelects a range of characters in a rich edit control.
SetTableParamsChanges the parameters of rows in a table.
SetTabStopsSets the tab stops in a multiline rich edit control.
SetTargetDeviceSets the target device and line width used for WYSIWYG formatting in a rich edit control.
SetTextExCombines the functionality of WM_SETTEXT and EM_REPLACESEL and adds the ability to set text using a code page and to use either Rich Text Format (RTF) rich text or plain text.
SetTextBoldSets the attribute of selected text or word to bold.
SetTextItalicSets the attribute of selected text or word to italic.
SetTextStrikeOutSets the attribute of selected text or word to strike out.
SetTextUnderlineSets the attribute of selected text or word to underline.
SetUIANameSets the maximum number of actions that can stored in the undo queue.
SetUndoLimitSets the maximum number of actions that can stored in the undo queue.
SetZoomSets the zoom ratio anywhere between 1/64 and 64.
ShowScrollBarShows or hides one of the scroll bars in the Text Host window.
StopGroupTypingStops the control from collecting additional typing actions into the current undo action.
StreamInReplaces the contents of a rich edit control with a stream of data provided by an application defined EditStreamCallback callback function.
StreamOutCauses a rich edit control to pass its contents to an application defined EditStreamCallback callback function.
UndoThis message undoes the last edit control operation in the control's undo queue.

CRichEditCtx File Operations Methods

NameDescription
NewDocOpens a new document.
OpenDocOpens a new document.
SaveDocSaves the document.
DocNameGets the file name of this document.
AppendDocFileAppends the contents of the specified RTF file.
InsertDocFileInserts the contents of the specified RTF file.
GetTextFromFileGets text from the specified file.
SaveRawTextSaves the raw contents of the rich edit control to a file.
SaveRtfSaves the contents of the rich edit control to a file in rtf format.
SaveRtfNoObjsSaves the contents of the rich edit control to a file in rtf format with spaces in place of COM objects.
SaveSelRtfSaves selection of the rich edit control to a file in rtf format.
SaveTextSaves the contents of the rich edit control in text format.
SaveSelTextSaves selection of the rich edit control in text format.
LoadRtfFromResourceLoads a rich text resource file into a rich edit control.

ITextDocument2 Methods and Properties

NameDescription
ActiveStoryGets/sets the active story.
AttachMsgFilterAttaches a new message filter to the edit instance.
BeginEditCollectionTurns on edit collection (also called undo grouping).
EndEditCollectionTurns off edit collection (also called undo grouping).
CaretTypeGets/sets the caret type.
CheckTextLimitChecks whether the number of characters to be added would exceed the maximum text limit.
DefaultTabStopGets/sets the default tab width.
DocumentFontGets/sets a font object that provides the default character format information for this instance of the Text Object Model (TOM) engine.
DocumentParaGets/sets an object that provides the default paragraph format information for this instance of the Text Object Model (TOM) engine.
EastAsianFlagsGets the East Asian flags.
EffectColorGets/sets the color used for special text attributes.
FreezeIncrements the freeze count.
UnfreezeDecrements the freeze count.
GetCallManagerGets the call manager.
ReleaseCallManagerReleases the call manager.
GetClientRectRetrieves the client rectangle of the rich edit control.
GetDisplaysGets the displays collection for this Text Object Model (TOM) engine instance.
GetGeneratorGets the name of the Text Object Model (TOM) engine.
GetImmContextGets the Input Method Manager (IMM) input context from the Text Object Model (TOM) host.
MainStoryGets the main story.
NewStoryNot implemented. Gets a new story.
ReleaseImmContextReleases an Input Method Manager (IMM) input context.
GetPreferredFontRetrieves the preferred font for a particular character repertoire and character position.
GetPropertyGets the value of a property.
SetPropertySets the value of a property.
GetStoryRetrieves the story that corresponds to a particular index.
GetStoryRangesGets the story collection object used to enumerate the stories in a document.
GetStoryRanges2Gets an object for enumerating the stories in a document.
GetStringsGets a collection of rich-text strings.
GetWindowGets the handle of the window that the Text Object Model (TOM) engine is using to display output.
MathPropertiesGets the math properties for the document.
NotificationModeGets/sets the notification mode.
NotifyNotifies the Text Object Model (TOM) engine client of particular Input Method Editor (IME) events.
RangeRetrieves a text range object for a specified range of content in the active story of the document.
RangeFromPointRetrieves a range for the content at or nearest to the specified point on the screen.
SavedGets/sets the Saved property.
SelectionGets the active selection.
Selection2Gets the active selection.
SetIMEInProgressSets the state of the Input Method Editor (IME) in-progress flag.
StoryCountGets the number of stories in the document.
SysBeepGenerates a system beep.
UpdateUpdates the selection and caret.
UpdateWindowNotifies the client that the view has changed and the client should update the view if the Text Object Model (TOM) engine is in-place active.

AfxCRichEditCtxPtr

Overloaded function that retrieves a pointer to the CRichEditCtxclass from the handle of the rich edit control or from the handle of its parent window and the control's identifier.

FUNCTION AfxCRichEditCtxPtr OVERLOAD (BYVAL hRichEdit AS HWND) AS CRichEditCtx PTR
FUNCTION AfxCRichEditCtxPtr OVERLOAD (BYVAL hParent AS HWND, BYVAL cID AS LONG) AS CRichEditCtx PTR
ParameterDescription
hRichEditHandle of the rich edit control.
ParameterDescription
hParentHandle of the parent window of the rich edit control.
cIDIdentifier of the rich edit control.
Return value

A pointer to the CRichEditCtx class.


CONSTRUCTOR

Creates an instance of the rich edit control.

CONSTRUCTOR CRichEditCtx (BYVAL pWindow AS CWindow PTR, BYVAL cID AS LONG_PTR, BYREF wszTitle AS WSTRING = "", _
   BYVAL x AS LONG = 0, BYVAL y AS LONG = 0, BYVAL nWidth AS LONG = 0, BYVAL nHeight AS LONG = 0, _
   BYVAL dwStyle AS DWORD = 0, BYVAL dwExStyle AS DWORD = 0, BYVAL lpParam AS LONG_PTR = 0)
ParameterDescription
pWindowPointer to the parent CWindowclass.
cIDThe control identifier, an integer value used to notify its parent about events. The application determines the control identifier; it must be unique for all controls with the same parent window.
wszTitleOptional. The text of the control.
xOptional. The x-coordinate of the upper-left corner of the window relative to the upper-left corner of the parent window's client area.
yOptional. The initial y-coordinate of the upper-left corner of the window relative to the upper-left corner of the parent window's client area.
nWidthOptional. The width of the control.
nHeightOptional. The height of the control.
dwStyleOptional. The window styles of the control being created.
Default styles: WS_VISIBLE OR WS_CHILD OR WS_TABSTOP OR ES_LEFT OR WS_HSCROLL OR WS_VSCROLL OR ES_AUTOHSCROLL OR ES_AUTOVSCROLL OR ES_MULTILINE OR ES_WANTRETURN OR ES_NOHIDESEL OR ES_SAVESEL
dwExStyleOptional. The extended window styles of the control being created.
Default extended style: WS_EX_CLIENTEDGE
lParamOptional. Pointer to custom data.
Usage example (dotted syntax)
DIM pRichEdit AS CRichEditCtx = CRichEditCtx(@pWindow, IDC_RICHEDIT, _
    "Rich Edit box", 100, 50, 300, 200)
Usage example (pointer syntax)
DIM pRichEdit AS CRichEditCtx PTR = NEW CRichEditCtx(@pWindow, IDC_RICHEDIT, _
    "Rich Edit box", 100, 50, 300, 200)

DESTRUCTOR

Called automatically when a class variable goes out of scope or is destroyed.

DESTRUCTOR CRichEditCtx

hRichEdit

Returns the handle of the rich edit control.

FUNCTION hRichEdit () AS HWND
Usage example
' // Create an instance of the CRichEditCtx class
DIM pRichEdit AS CRichEditCtx = CRichEditCtx(@pWindow, IDC_RICHEDIT, "RichEditbox", 100, 50, 300, 200)
' // Set the focus in the control
DIM hRichEdit AS HWND = pRichEdit.hRichEdit

ScalingRatio

Gets/sets the scaling ratio.

(GET) PROPERTY ScalingRatio () AS SINGLE
(SET) PROPERTY ScalingRatio (BYVAL Ratio AS SINGLE)
FUNCTION GetScalingRatio () AS SINGLE
SUB SetScalingRatio (BYVAL ratio AS SINGLE)
Remarks

The scaling ratio is used by the InsertImage and InsertObject methods to scale images according to the DPI settings of your computer. Its initial value is the scaling ratio used by its parent window, but you can change it with this property. Setting a value or 1 disables scaling.

Usage examples
DIM ratio AS LONG = pRichEdit.ScalingRatio
pRichEdit.ScalingRatio = ratio
DIM ratio AS LONG = pRichEdit.GetScalingRatio
pRichEdit.SetScalingRatio(ratio)

SetWysiwygPrint

Sets the target printer device and line width used for "what you see is what you get" (WYSIWYG) formatting in a rich edit control.

FUNCTION SetWysiwygPrint (BYREF wszPrinterName AS WSTRING = "") AS BOOLEAN
ParameterDescription
wszPrinterNameThe printer name, e.g. "OKI B410d" or the "Microsoft Print to PDF" virtual printer. If wszPrinterName is empty, the control will use the default printer.
Return value

A boolean true (-1) or false (0).

RestoreTargetDevice

Sets the target device to the device context of the rich edit control.

FUNCTION RestoreTargetDevice () AS BOOLEAN
Return value

A boolean true (-1) or false (0).

AutoCorrectProc

Gets/sets a pointer to the application-defined AutoCorrectProc callback function.

(GET) PROPERTY AutoCorrectProc () AS LONG_PTR
(SET) PROPERTY AutoCorrectProc (BYVAL pfn AS LONG_PTR)
FUNCTION GetAutoCorrectProc () AS LONG_PTR
FUNCTION SetAutoCorrectProc (BYVAL pfn AS LONG_PTR) AS HRESULT
ParameterDescription
pfnPointer to the AutoCorrectProc application-defined callback function.
Return value

(GET) A pointer to the application-defined AutoCorrectProc callback function.

(SET) If the operation succeeds, the return value is zero. If the operation fails, the return value is a nonzero value.


AutoUrlDetect

Gets/sets whether the auto URL detection is turned on in the rich edit control.

(GET) PROPERTY AutoUrlDetect () AS BOOLEAN
(SET) PROPERTY AutoUrlDetect (BYVAL fUrlDetect AS LONG)
FUNCTION GetAutoUrlDetect () AS BOOLEAN
FUNCTION SetAutoUrlDetect (BYVAL fUrlDetect AS LONG) AS HRESULT
FUNCTION DisableAutoUrlDetect () AS BOOLEAN
FUNCTION EnableAutoUrlDetect (BYVAL fUrlDetect AS LONG) AS HRESULT
ParameterDescription
fUrlDetect(SET) Specify 0 to disable automatic link detection, or one of the following values to enable various kinds of detection.
fUrlDetect valueDescription
AURL_DISABLEMIXEDLGCWindows 8: Disable recognition of domain names that contain labels with characters belonging to more than one of the following scripts: Latin, Greek, and Cyrillic.
AURL_ENABLEDRIVELETTERSWindows 8: Recognize file names that have a leading drive specification, such as c:\temp.
AURL_ENABLEEAThis value is deprecated; use AURL_ENABLEEAURLS instead.
AURL_ENABLEEAURLSRecognize URLs that contain East Asian characters.
AURL_ENABLEEMAILADDRWindows 8: Recognize email addresses.
AURL_ENABLETELNOWindows 8: Recognize telephone numbers.
AURL_ENABLEURWindows 8: Recognize URLs that include the path.
Return value

(GET) If auto-URL detection is active, the return value is true (-1). If auto-URL detection is inactive, the return value is false (0).

(SET) If the message succeeds, the return value is zero. If the message fails, the return value is a nonzero value. For example, the message might fail due to insufficient memory or an invalid detection option.

Remarks

If automatic URL detection is enabled (that is, fUrlDetect includes AURL_ENABLEURL), the rich edit control scans any modified text to determine whether the text matches the format of a URL (or more generally in Windows 8 or later an IRI International Resource Identifier). The control detects URLs that begin with the following scheme names:

  • callto
  • file
  • ftp
  • gopher
  • http
  • https
  • mailto
  • news
  • notes
  • nntp
  • onenote
  • outlook
  • prospero
  • tel
  • telnet
  • wais
  • webcal

When automatic link detection is enabled, the rich edit control removes the CFE_LINK effect from modified text that does not have a format recognized by the control. If your application uses the CFE_LINK effect to mark other types of text, do not enable automatic link detection. The rich edit control does not check whether a detected link exists; that responsibility belongs to the client.

A rich edit control sends the EN_LINK notification when it receives various messages while the mouse pointer is over text that has the CFE_LINK effect.


BidiOptions

Gets/sets the current state of the bidirectional options in the rich edit control.

(GET) PROPERTY BidiOptions () AS .BIDIOPTIONS
(SET) PROPERTY BidiOptions (BYREF opt AS .BIDIOPTIONS)
FUNCTION GetBidiOptions () AS .BIDIOPTIONS
SUB SetBidiOptions (BYREF opt AS .BIDIOPTIONS)
ParameterDescription
opt(SET) A BIDIOPTIONS structure that indicates how to set the state of the bidirectional options in the rich edit control.
Return value

(GET) A BIDIOPTIONS structure with the current state of the bidirectional options in the rich edit control. The values of the wMask and wEffects contain the current state of the bidirectional options in the rich edit control.

(SET) This property does not return a result.

Remarks (SET property)

The rich edit control must be in plain text mode or BidiOptions will not do anything.

In plain text controls, BidiOptions automatically determines the paragraph direction and/or alignment based on the context rules. These rules state that the direction and/or alignment is derived from the first strong character in the control. A strong character is one from which text direction can be determined (see Unicode Standard version 2.0). The paragraph direction and/or alignment is applied to the default format.

BidiOptions only switches the default paragraph format to RTL (right to left) if it finds an RTL character.


CaretPos

Gets/sets the caret position.

(GET) PROPERTY CaretPos () AS DWORD
(SET) PROPERTY CaretPos (BYVAL dwPos AS DWORD)
FUNCTION GetCaretPos () AS DWORD
SUB SetCaretPos (BYVAL dwPos AS DWORD)
ParameterDescription
dwPos(SET) The caret position. If you pass a value of -1, the caret will be positioned at the end of the document.
Return value

(GET) The caret position.

(SET) This property does not return a result.


CharFormat

Gets/sets the current character formatting in a rich edit control.

(GET) PROPERTY CharFormat (BYVAL fOption AS DWORD) AS CHARFORMATW
(SET) PROPERTY CharFormat (BYVAL chfmt AS DWORD, BYREF cf AS CHARFORMATW)
FUNCTION GetCharFormat (BYVAL fOption AS DWORD) AS CHARFORMATW
FUNCTION SetCharFormat (BYVAL chfmt AS DWORD, BYREF cf AS CHARFORMATW) AS BOOLEAN

Gets/sets the default character formatting in a rich edit control.

(GET) PROPERTY DefaultCharFormat () AS CHARFORMATW
(SET) PROPERTY DefaultCharFormat (BYREF cf AS CHARFORMATW)
FUNCTION GetDefaultCharFormat () AS CHARFORMATW
FUNCTION SetDefaultCharFormat (BYREF cf AS CHARFORMATW) AS BOOLEAN

Gets/sets the character formatting attributes of the current selection.

(GET) PROPERTY SelectionCharFormat () AS CHARFORMATW
(SET) PROPERTY SelectionCharFormat (BYREF cf AS CHARFORMATW)
FUNCTION GetSelectionCharFormat () AS CHARFORMATW
FUNCTION SetSelectionCharFormat (BYREF cf AS CHARFORMATW) AS BOOLEAN

Gets/sets the character formatting attributes for the currently selected word.

(GET) PROPERTY WordCharFormat () AS CHARFORMATW
(SET) PROPERTY WordCharFormat (BYREF cf AS CHARFORMATW)
FUNCTION GetWordCharFormat () AS CHARFORMATW
FUNCTION SetWordCharFormat (BYREF cf AS CHARFORMATW) AS BOOLEAN
ParameterDescription
fOption(GET) Specifies the range of text from which to retrieve formatting. It can be one of the following values.
SCF_DEFAULT The default character formatting.
SCF_SELECTION The current selection's character formatting.
ParameterDescription
chfmt(SET) Character formatting that applies to the control. If this parameter is zero, the default character format is set. Otherwise, it can be one of the following values (see Formatting values below).
cf(SET) A CHARFORMATW structure specifying the character formatting to use. Only the formatting attributes specified by the dwMask member are changed. The szFaceName and bCharSet members may be overruled when invalid for characters, for example: Arial on kanji characters.
Formatting valueMeaning
SCF_ALLApplies the formatting to all text in the control. Not valid with SCF_SELECTION or SCF_WORD.
SCF_ASSOCIATEFONTRichEdit 4.1: Associates a font to a given script, thus changing the default font for that script. To specify the font, use the following members of CHARFORMAT2: yHeight, bCharSet, bPitchAndFamily, szFaceName, and lcid.
SCF_ASSOCIATEFONT2RichEdit 4.1: Associates a surrogate (plane-2) font to a given script, thus changing the default font for that script. To specify the font, use the following members of CHARFORMAT2: yHeight, bCharSet, bPitchAndFamily, szFaceName, and lcid.
SCF_CHARREPFROMLCIDGets the character repertoire from the LCID.
SCF_DEFAULTRichEdit 4.1: Sets the default font for the control.
SPF_DONTSETDEFAULTPrevents setting the default paragraph format when the rich edit control is empty.
SCF_NOKBUPDATERichEdit 4.1: Prevents keyboard switching to match the font. For example, if an Arabic font is set, normally the automatic keyboard feature for Bidi languages changes the keyboard to an Arabic keyboard.
SCF_SELECTIONApplies the formatting to the current selection. If the selection is empty, the character formatting is applied to the insertion point, and the new character format is in effect only until the insertion point changes.
SPF_SETDEFAULTSets the default paragraph formatting attributes.
SCF_SMARTFONTApply the font only if it can handle script.
SCF_USEUIRULESRichEdit 4.1: Used with SCF_SELECTION. Indicates that format came from a toolbar or other UI tool, so UI formatting rules should be used instead of literal formatting.
SCF_WORDApplies the formatting to the selected word or words. If the selection is empty but the insertion point is inside a word, the formatting is applied to the word. The SCF_WORD value must be used in conjunction with the SCF_SELECTION value.
Return value

(GET) Returns a CHARFORMATW structure with the attributes of the first character. The dwMask member specifies which attributes are consistent throughout the entire selection. For example, if the entire selection is either in italics or not in italics, CFM_ITALIC is set; if the selection is partly in italics and partly not, CFM_ITALIC is not set.

(SET) If the operation succeeds, the return value is a nonzero value. If the operation fails, the return value is zero. Call GetErrorInfo to get information about the result.

Usage examples

Select text and change color

pRichEdit.ExSetSel(98, 113)         ' // Select word at position 98, 113
DIM cf AS CHARFORMAT
cf.dwMask = CFM_COLOR               ' // Let's set the color
cf.crTextColor = BGR(255, 0, 0)     ' // Red color
pRichEdit.SelectionCharFormat = cf  ' // Set the color
pRichEdit.HideSelection(TRUE)       ' // Hide selection

Select text and make it bold

pRichEdit.ExSetSel(98, 113)         ' // Select word at position 98, 113
DIM cf AS CHARFORMAT
cf.dwMask = CFM_BOLD                ' // The CFE_BOLD value of the dwEffects member is valid.
cf.dwEffects = CFE_BOLD             ' // Characters are bold
pRichEdit.SelectionCharFormat = cf  ' // Set the format
pRichEdit.HideSelection(TRUE)       ' // Hide selection

Select text and change the font height

pRichEdit.ExSetSel(98, 113)          ' // Select word at position 98, 113
DIM cf AS CHARFORMAT
cf.dwMask = CFM_SIZE                 ' // The yHeight member is valid.
cf.yHeight = 12 * 20                 ' // Character height, in twips (1/1440 of an inch or 1/20 of a printer's point)
pRichEdit.SelectionCharFormat = cf   ' // Set the format
pRichEdit.HideSelection(TRUE)        ' // Hide selection

CTFModeBias

Gets/sets the Text Services Framework mode bias values for a Microsoft Rich Edit control.

(GET) PROPERTY CTFModeBias () AS LONG
(SET) PROPERTY CTFModeBias (BYVAL nModeBias AS LONG)
FUNCTION GetCTFModeBias () AS LONG
FUNCTION SetCTFModeBias (BYVAL nModeBias AS LONG) AS HRESULT
ParameterDescription
nModeBias(SET) Mode bias value. This can be one of the following values below.
Mode bias valueMeaning
CTFMODEBIAS_DEFAULTThere is no mode bias.
CTFMODEBIAS_FILENAMEThe bias is to a filename.
CTFMODEBIAS_NAMEThe bias is to a name.
CTFMODEBIAS_READINGThe bias is to the reading.
CTFMODEBIAS_DATETIMEThe bias is to a date or time.
CTFMODEBIAS_CONVERSATIONThe bias is to a conversation.
CTFMODEBIAS_NUMERICThe bias is to a number.
CTFMODEBIAS_HIRAGANAThe bias is to hiragana strings.
CTFMODEBIAS_KATAKANAThe bias is to katakana strings.
CTFMODEBIAS_HANGULThe bias is to Hangul characters.
CTFMODEBIAS_HALFWIDTHKATAKANAThe bias is to half-width katakana strings.
CTFMODEBIAS_FULLWIDTHALPHANUMERICThe bias is to full-width alphanumeric characters.
CTFMODEBIAS_HALFWIDTHALPHANUMERICThe bias is to half-width alphanumeric characters.
Return value

(GET) The current Text Services Framework mode bias value.

(SET) If successful, the return value is the new TSF mode bias value. If unsuccessful, the return value is the old TSF mode bias value.

Remarks

When a Microsoft Rich Edit application uses TSF, it can select the TSF mode bias. This message sets the criteria by which an alternative choice appears at the top of the list for selection.


CTFOpenStatus

Gets/sets if the Text Services Framework (TSF) keyboard is open or closed.

(GET) PROPERTY CTFOpenStatus () AS BOOLEAN
(SET) PROPERTY CTFOpenStatus (BYVAL fTSFkbd AS LONG)
FUNCTION GetCTFOpenStatus () AS BOOLEAN
FUNCTION SetCTFOpenStatus (BYVAL fTSFkbd AS LONG) AS BOOLEAN
ParameterDescription
fTSFkbdTo turn on the TSF keyboard, use TRUE. To turn off the TSF keyboard, use FALSE.
Return value

(GET) If the TSF keyboard is open, the return value is TRUE. Otherwise, it is FALSE.

(SET) If successful, it returns TRUE. If unsuccessful, it returns FALSE. Call the (GET) CTFOpenStatus property to check if the value has changed.


EditStyle

Gets/sets the current edit style flags.

(GET) PROPERTY EditStyle () AS DWORD
(SET) PROPERTY EditStyle (BYVAL fStyle AS LONG, BYVAL fMask AS LONG)
FUNCTION GetEditStyle () AS DWORD
FUNCTION SetEditStyle (BYVAL fStyle AS LONG, BYVAL fMask AS LONG) AS HRESULT
ParameterDescription
fStyleSpecifies one or more edit style flags. For a list of possible values, see the table below.
fMaskA mask consisting of one or more of the fStyle values. Only the values specified in this mask will be set or cleared. This allows a single flag to be set or cleared without reading the current flag states.
Edit Style FlagDescription
SES_BEEPONMAXTEXTRich Edit will call the system beeper if the user attempts to enter more than the maximum characters.
SES_BIDITurns on bidirectional processing. This is automatically turned on by Rich Edit if any of the following window styles are active: WS_EX_RIGHT, WS_EX_RTLREADING, WS_EX_LEFTSCROLLBAR. However, this setting is useful for handling these window styles when using a custom implementation of ITextHost (default: 0).
SES_CTFALLOWEMBEDWindows XP with SP1: Allow embedded objects to be inserted using TSF (default: 0).
SES_CTFALLOWPROOFINGWindows XP with SP1: Allows TSF proofing tips (default: 0).
SES_CTFALLOWSMARTTAGWindows XP with SP1: Allows TSF SmartTag tips (default: 0).
SES_CTFNOLOCKWindows 8: Do not allow the TSF lock read/write access. This pauses TSF input.
SES_DEFAULTLATINLIGAWindows 8: Fonts with an fi ligature are displayed with default OpenType features resulting in improved typography (default: 0).
SES_DRAFTMODEWindows XP with SP1: Use draft mode fonts to display text. Draft mode is an accessibility option where the control displays the text with a single font; the font is determined by the system setting for the font used in message boxes. For example, accessible users may read text easier if it is uniform, rather than a mix of fonts and styles (default: 0).
SES_EMULATE10Windows 8: Emulate RichEdit 1.0 behavior.
Note: If you really want this behavior, use the Windows riched32.dll instead of riched20.dll or msftedit.dll. Riched32.dll had more functionality.
SES_EMULATESYSEDITWhen this bit is on, rich edit attempts to emulate the system edit control (default: 0).
SES_EXTENDBACKCOLORExtends the background color all the way to the edges of the client rectangle (default: 0).
SES_HIDEGRIDLINESWindows XP with SP1: If the width of table gridlines is zero, gridlines are not displayed. This is equivalent to the hide gridlines feature in Word's table menu (default: 0).
SES_HYPERLINKTOOLTIPSWindows 8: When the cursor is over a link, display a tooltip with the target link address (default: 0).
SES_LOGICALCARETWindows 8: Provide logical caret information instead of a caret bitmap as described in ITextHost.TxSetCaretPos) (default: 0).
SES_LOWERCASEConverts all input characters to lowercase (default: 0).
SES_MAPCPSObsolete. Do not use.
SES_MULTISELECTWindows 8: Enable multiselection with individual mouse selections made while the Ctrl key is pressed (default: 0).
SES_NOEALINEHEIGHTADJUSTWindows 8: Do not adjust line height for East Asian text (default: 0 which adjusts the line height by 15%).
SES_NOFOCUSLINKNOTIFYSends EN_LINK notification from links that do not have focus.
SES_NOIMEDisallows IMEs for this instance of the rich edit control (default: 0).
SES_NOINPUTSEQUENCECHKWhen this bit is on, rich edit does not verify the sequence of typed text. Some languages (such as Thai and Vietnamese) require verifying the input sequence order before submitting it to the backing store (default: 0).
SES_SCROLLONKILLFOCUSWhen KillFocus occurs, scroll to the beginning of the text (character position equal to 0) (default: 0).
SES_SMARTDRAGDROPWindows 8: Add or delete a space according to the context when dropping text (default: 0).
SES_USECRLFObsolete. Do not use.
SES_WORDDRAGDROPWindows 8: If word select is active, ensure that the drop location is at a word boundary (default: 0).
SES_UPPERCASEConverts all input characters to uppercase (default: 0).
SES_USEAIMMUses the Active IMM input method component that ships with Internet Explorer 4.0 or later (default: 0).
SES_USEATFONTWindows XP with SP1: Uses an @ font, which is designed for vertical text; this is used with the ES_VERTICAL window style. The name of an @ font begins with the @ symbol, for example, "@Batang" (default: 0, but is automatically turned on for vertical text layout).
SES_USECTFWindows XP with SP1: Turns on TSF support. (default: 0).
SES_XLTCRCRLFTOCRTurns on translation of CRCRLFs to CRs. When this bit is on and a file is read in, all instances of CRCRLF will be converted to hard CRs internally. This will affect the text wrapping. Note that if such a file is saved as plain text, the CRs will be replaced by CRLFs. This is the .txt standard for plain text (default: 0, which deletes CRCRLFs on input).
Return value

(GET) Returns the current edit style flags, which can include one or more of the following values (see table above).

(SET) The return value is the state of the edit style flags after the rich edit control has attempted to implement your edit style changes. The edit style flags are a set of flags that indicate the current edit style. Call the (GET) EditStyle property to check if the value has changed.


EditStyleEx

Gets/sets the extended edit style flags.

(GET) PROPERTY EditStyleEx () AS DWORD
(SET) PROPERTY EditStyleEx (BYVAL fStyle AS LONG, BYVAL fMask AS LONG)
FUNCTION GetEditStyleEx () AS DWORD
FUNCTION SetEditStyleEx (BYVAL fStyle AS LONG, BYVAL fMask AS LONG) AS HRESULT
ParameterDescription
fStyleSpecifies one or more edit style flags. For a list of possible values, see table below.
fMaskA mask consisting of one or more of the fStyle values. Only the values specified in this mask will be set or cleared. This allows a single flag to be set or cleared without reading the current flag states.
Edit style flagDescription
SES_EX_HANDLEFRIENDLYURLDisplay friendly name links with the same text color and underlining as automatic links, provided that temporary formatting isn't used or uses text autocolor (default: 0).
SES_EX_MULTITOUCHEnable touch support in Rich Edit. This includes selection, caret placement, and context-menu invocation. When this flag is not set, touch is emulated by mouse commands, which do not take touch-mode specifics into account (default: 0).
SES_EX_NOACETATESELECTIONDisplay selected text using classic Windows selection text and background colors instead of background acetate color (default: 0).
SES_EX_NOMATHDisable insertion of math zones (default: 1). To enable math editing and display, call the EditStyleEx property with fStyle set to 0, and fMask set to SES_EX_NOMATH.
SES_EX_NOTABLEDisable insertion of tables. The InsertTable method returns E_FAIL and RTF tables are skipped (default: 0).
SES_EX_USESINGLELINEEnable a multiline control to act like a single-line control with the ability to scroll vertically when the single-line height is greater than the window height (default: 0).
SES_HIDETEMPFORMATHide temporary formatting that is created when Reset method of the ITextFont is called with tomApplyTmp. For example, such formatting is used by spell checkers to display a squiggly underline under possibly misspelled words.
SES_EX_USEMOUSEWPARAMUse wParam when handling the WM_MOUSEMOVE message and do not call GetAsyncKeyState.
Return value

(GET) Returns the state of the edit style flags.

(SET) The return value is the state of the edit style flags after the rich edit control has attempted to implement your edit style changes. The edit style flags are a set of flags that indicate the current edit style. Call the (GET) EditStyleEx property to check if the value has changed.


EllipsisMode

Gets/sets the current ellipsis mode. When enabled, an ellipsis ( ) is displayed for text that doesn't fit in the display window. The ellipsis is only used when the control isn't active. When active, scroll bars are used to reveal text that doesn't fit into the display window.

(GET) PROPERTY EllipsisMode () AS DWORD
(SET) PROPERTY EllipsisMode (BYVAL fMode AS DWORD)
FUNCTION GetEllipsisMode () AS DWORD
FUNCTION SetEllipsisMode (BYVAL fMode AS DWORD) AS BOOLEAN
ParameterDescription
fMode(SET) One of the values listed below.
ValueMeaning
ELLIPSIS_NONENo ellipsis is used.
ELLIPSIS_ENDEllipsis at the end (forced break).
ELLIPSIS_WORDEllipsis at the end (word break).

The bits for these values all fit in the ELLIPSIS_MASK.

Return value

A boolean true(-1) or false (0).


EllipsisState

Gets the current ellipsis state.

PROPERTY EllipsisState () AS BOOLEAN
FUNCTION GetEllipsisState () AS BOOLEAN
Return value

Returns a boolean true (-1) if an ellipsis is being displayed of false (0) otherwise.


EventMask

Gets/sets the event mask for a rich edit control. The event mask specifies which notification messages the control sends to its parent window.

(GET) PROPERTY EventMask () AS DWORD
(SET) PROPERTY EventMask (BYVAL fMask AS DWORD)
FUNCTION GetEventMask () AS DWORD
FUNCTION SetEventMask (BYVAL fMask AS DWORD) AS HRESULT
ParameterDescription
fMaskNew event mask for the rich edit control. For a list of event masks, see the following table.
FlagDescription
ENM_CHANGESends EN_CHANGE notifications.
ENM_CLIPFORMATSends EN_CLIPFORMAT notifications.
ENM_CORRECTTEXTSends EN_CORRECTTEXT notifications.
ENM_DRAGDROPDONESends EN_DRAGDROPDONE notifications.
ENM_DROPFILESSends EN_DROPFILES notifications.
ENM_IMECHANGEMicrosoft Rich Edit 1.0 only: Sends EN_IMECHANGE notifications when the IME conversion status has changed. Only for Asian-language versions of the operating system.
ENM_KEYEVENTSSends EN_MSGFILTER notifications for keyboard events.
ENM_LINKRich Edit 2.0 and later: Sends EN_LINK notifications when the mouse pointer is over text that has the CFE_LINK and one of several mouse actions is performed.
ENM_LOWFIRTFSends EN_LOWFIRTF notifications.
ENM_MOUSEEVENTSSends EN_MSGFILTER notifications for mouse events.
ENM_OBJECTPOSITIONSSends EN_OBJECTPOSITIONS notifications.
ENM_PARAGRAPHEXPANDEDSends EN_PARAGRAPHEXPANDED notifications.
ENM_PROTECTEDSends EN_PROTECTED notifications.
ENM_REQUESTRESIZESends EN_REQUESTRESIZE notifications.
ENM_SCROLLSends EN_HSCROLL and EN_VSCROLL notifications.
ENM_SCROLLEVENTSSends EN_MSGFILTER notifications for mouse wheel events.
ENM_SELCHANGESends EN_SELCHANGE notifications.
ENM_UPDATESends EN_UPDATE notifications.
Rich Edit 2.0 and later: this flag is ignored and the EN_UPDATE notifications are always sent. However, if Rich Edit 3.0 emulates Microsoft Rich Edit 1.0, you must use this flag to send EN_UPDATE notifications.
Return value

(GET) The event mask for this rich edit control.

(SET) Returns the previous event mask. Call the (GET) EventMask property to check if the value has changed.

Remarks

The default event mask is ENM_NONE in which case no notifications are sent to the parent window.


FirstVisibleLine

Gets the zero-based index of the uppermost visible line in a multiline rich edit control.

PROPERTY FirstVisibleLine () AS LONG
FUNCTION GetFirstVisibleLine () AS LONG
Return value

The return value is the zero-based index of the uppermost visible line in a multiline edit control.

For single-line rich edit controls, the return value is zero.


HyphenateInfo

Gets/sets information about hyphenation for a Microsoft Rich Edit control.

(GET) PROPERTY HyphenateInfo () AS .HYPHENATEINFO
(SET) PROPERTY HyphenateInfo (BYREF hinfo AS .HYPHENATEINFO)
FUNCTION GetHyphenateInfo () AS .HYPHENATEINFO
FUNCTION SetHyphenateInfo (BYREF info AS .HYPHENATEINFO) AS HRESULT
ParameterDescription
hinfo(SET) A HYPHENATEINFO structure.
Return value

(GET) A HYPHENATEINFO structure.


IMEModeBias

Gets/sets the Input Method Editor (IME) mode bias for a Microsoft Rich Edit control.

PROPERTY IMEModeBias () AS DWORD
PROPERTY IMEModeBias (BYVAL nModeBias AS LONG)
FUNCTION GetIMEModeBias () AS DWORD
FUNCTION SetIMEModeBias (BYVAL nModeBias AS LONG) AS HRESULT
ParameterDescription
nModeBiasMode bias value. This can be one of the following values below.
Mode bias valueMeaning
CTFMODEBIAS_DEFAULTThere is no mode bias.
CTFMODEBIAS_FILENAMEThe bias is to a filename.
CTFMODEBIAS_NAMEThe bias is to a name.
CTFMODEBIAS_READINGThe bias is to the reading.
CTFMODEBIAS_DATETIMEThe bias is to a date or time.
CTFMODEBIAS_CONVERSATIONThe bias is to a conversation.
CTFMODEBIAS_NUMERICThe bias is to a number.
CTFMODEBIAS_HIRAGANAThe bias is to hiragana strings.
CTFMODEBIAS_KATAKANAThe bias is to katakana strings.
CTFMODEBIAS_HANGULThe bias is to Hangul characters.
CTFMODEBIAS_HALFWIDTHKATAKANAThe bias is to half-width katakana strings.
CTFMODEBIAS_FULLWIDTHALPHANUMERICThe bias is to full-width alphanumeric characters.
CTFMODEBIAS_HALFWIDTHALPHANUMERICThe bias is to half-width alphanumeric characters.
Return value

(GET) This message returns the current IME mode bias setting.

(SET) If successful, the return value is the new TSF mode bias value. If unsuccessful, the return value is the old TSF mode bias value. Call the (GET) IMEModeBias property to check if the value has changed.

Remarks

(GET) To get the Text Services Framework mode bias, use the CTFModeBias property.

(SET) When a Microsoft Rich Edit application uses TSF, it can select the TSF mode bias. This message sets the criteria by which an alternative choice appears at the top of the list for selection.

The application should call the IsIME method before calling these properties.


IMEOptions

Gets/sets the current Input Method Editor (IME) options. This message is available only in Asian-language versions of the operating system.

(GET) PROPERTY IMEOptions () AS DWORD
(SET) PROPERTY IMEOptions (BYVAL fCoop AS LONG, BYVAL fOptions AS LONG)
FUNCTION GetIMEOptions () AS DWORD
FUNCTION SetIMEOptions (BYVAL fCoop AS LONG, BYVAL fOptions AS LONG) AS HRESULT
ParameterDescription
fCoop(SET) Specifies one of the following values.
ECOOP_SET. Sets the options to those specified by fOptions.
COOP_OR. Combines the specified options with the current options.
ECOOP_AND. Retains only those current options that are also specified by fOptions.
ECOOP_XOR. Logically exclusive OR the current options with those specified by fOptions.
fOptions(SET) Specifies one of more of the following values.
IMF_CLOSESTATUSWINDOW. Closes the IME status window when the control receives the input focus.
IMF_FORCEACTIVE. Activates the IME when the control receives the input focus.
IMF_FORCEDISABLE. Disables the IME when the control receives the input focus.
IMF_FORCEENABLE. Enables the IME when the control receives the input focus.
IMF_FORCEINACTIVE. Inactivates the IME when the control receives the input focus.
IMF_FORCENONE. Disables IME handling.
IMF_FORCEREMEMBER. Restores the previous IME status when the control receives the input focus.
IMF_MULTIPLEEDIT. Specifies that the composition string will not be canceled or determined by focus changes. This allows an application to have separate composition strings on each rich edit control.
IMF_VERTICAL. Note: used in Rich Edit 2.0 and later.
Return value

(GET) Returns one or more of the IME option flag values described in the fOptions parameter of the SET property.

(SET) If the operation succeeds, the return value is a nonzero value. If the operation fails, the return value is zero. Call the (GET) ImeOptions property to check if the value has changed.


LangOptions

Gets/sets a rich edit control's option settings for Input Method Editor (IME) and Asian language support.

(GET) PROPERTY LangOptions () AS DWORD
(SET) PROPERTY LangOptions (BYVAL lgoptions AS LONG)
FUNCTION GetLangOptions () AS DWORD
FUNCTION SetLangOptions (BYVAL lgoptions AS LONG) AS HRESULT
ParameterDescription
lgoptions(SET) Specifies the language options. For a list of possible values, see table below.
FlagDescription
IMF_AUTOFONTIf this flag is set, the control automatically changes fonts when the user explicitly changes to a different keyboard layout. It is useful to turn off IMF_AUTOFONT for universal Unicode fonts. This option is turned on by default (1).
IMF_AUTOFONTSIZEADJUSTIf this flag is set, the control scales font-bound font sizes from insertion point size according to script. For example, Asian fonts are slightly larger than Western ones. This option is turned on by default (1).
IMF_AUTOKEYBOARDIf this flag is set, the control automatically changes the keyboard layout when the user explicitly changes to a different font, or when the user explicitly changes the insertion point to a new location in the text. Will be turned on automatically for bidirectional controls. For all other controls, it is turned off by default. This option is turned off by default (0).
IMF_DISABLEAUTOBIDIAUTOKEYBOARDWindows 8: If this flag is set, the control uses language neutral logic for automatic keyboard switching. This option is turned off by default (0).
IMF_DUALFONTIf this flag is set, the control uses dual-font mode. Used for Asian language support. The control uses an English font for ASCII text and a Asian font for Asian text. This option is turned on by default (1).
IMF_IMEALWAYSSENDNOTIFYThis flag controls how the rich edit control notifies the client during IME composition:
0: No EN_CHANGE or EN_SELCHANGE notifications during undetermined state. Send notification when the final string comes in. This is the default.
1: Send EN_CHANGE and EN_SELCHANGE events during undetermined state.
IMF_IMECANCELCOMPLETEThis flag determines how the control uses the composition string of an IME if the user cancels it. If this flag is set, the control discards the composition string. If this flag is not set, the control uses the composition string as the result string. This option is turned off by default (0).
IMF_NOIMPLICITLANGWindows 8: If this flag is set, disable stamping keyboard input with the keyboard language and ensuring that non-East Asian language IDss are compatible with the character repertoire. This option is turned off by default (0).
IMF_NOKBDLIDFIXUPWindows 8: If this flag is set, the rich edit control disables stamping keyboard language on an empty control. This option is turned off by default (0).
IMF_SPELLCHECKINGWindows 8: If this flag is set, the rich edit control turns on spell checking. This option is turned off by default (0).
IMF_TKBAUTOCORRECTIONWindows 8: If this flag is set, enable touch keyboard autocorrect. This option is turned off by default (0).
IMF_TKBPREDICTIONWindows 10: Ignored.
Windows 8: If this flag is set, the rich edit control enables touch keyboard prediction. This option is turned off by default (0).
IMF_UIFONTSUse user-interface default fonts. This option is turned off by default (0).
Return value

(GET) Returns the IME and Asian language settings, which can be zero or more of the above flags.

(SET) Returns a value of 1. Call the (GET) LangOptions property to check the value.

Remarks

The IMF_AUTOFONT flag is set by default. The IMF_AUTOKEYBOARD and IMF_IMECANCELCOMPLETE flags are cleared by default.


LimitText

Gets/sets the current text limit for a rich edit control. The text limit is the maximum amount of text that the user can type into the edit control.

(GET) PROPERTY LimitText () AS LONG
(SET) PROPERTY LimitText (BYVAL chMax AS DWORD)
ParameterDescription
chMax(SET) The maximum number of characters the user can enter. If this parameter is zero, the text length is set to 64,000 characters.
Return value

(GET) The return value is the text limit.

(SET) The set property does not return a value.

Remarks

(SET) LimitText limits only the text the user can enter. It does not affect any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control by the Text property. If an application uses the Text property to place more text into an edit control than is specified by the LimitText property, the user can edit the entire contents of the edit control.


GetLimitText

Gets the current text limit for a rich edit control. The text limit is the maximum amount of text that the user can type into the edit control.

FUNCTION GetLimitText () AS LONG
Return value

The return value is the text limit.


SetLimitText

Sets the current text limit for a rich edit control. The text limit is the maximum amount of text that the user can type into the edit control.

SUB SetLimitText (BYVAL chMax AS DWORD)
ParameterDescription
chMaxThe maximum number of characters the user can enter. If this parameter is zero, the text length is set to 64,000 characters.
Return value

The set property does not return a value.

Remarks

SetLimitText limits only the text the user can enter. It does not affect any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control by the SetText method. If an application uses the SetText method to place more text into an edit control than is specified by the SetLimitText method, the user can edit the entire contents of the edit control.


Modify

Gets/sets the state of a rich edit control's modification flag. The flag indicates whether the contents of the rich edit control have been modified.

(GET) PROPERTY Modify () AS LONG
(SET) PROPERTY Modify (BYVAL fModify AS LONG)
FUNCTION GetModify () AS LONG
SUB SetModify (BYVAL fModify AS LONG)
FUNCTION IsModified () AS BOOLEAN
ParameterDescription
fModify(SET) The new value for the modification flag. A value of TRUE indicates the text has been modified, and a value of FALSE indicates it has not been modified.
Return value

(GET) If the contents of edit control have been modified, the return value is nonzero; otherwise, it is zero.

(SET) The set property does not return a value.

Remarks

The system automatically clears the modification flag to zero when the control is created. If the user changes the control's text, the system sets the flag to nonzero. You can use the (SET) Modify property to set or clear the flag.


Options

Gets/sets the options for a rich edit control.

(GET) PROPERTY Options () AS DWORD
(SET) PROPERTY Options (BYVAL fCoop AS LONG, BYVAL fOptions AS LONG)
FUNCTION GetOptions () AS DWORD
FUNCTION SetOptions (BYVAL fCoop AS LONG, BYVAL fOptions AS LONG) AS DWORD
ParameterDescription
fCoopSpecifies the operation, which can be one of these values.
ECOOP_SET. Sets the options to those specified by fOptions.
ECOOP_OR. Combines the specified options with the current options.
ECOOP_AND. Retains only those current options that are also specified by fOptions.
ECOOP_XOR. Logically exclusive OR the current options with those specified by fOptions.
fOptionsSpecifies one or more of the following values.
ECO_AUTOWORDSELECTION- Automatic selection of word on double-click.
ECO_AUTOVSCROLL. Same as ES_AUTOVSCROLL style.
ECO_AUTOHSCROLL. Same as ES_AUTOHSCROLL style.
ECO_NOHIDESEL. Same as ES_NOHIDESEL style.
ECO_READONLY. Same as ES_READONLY style.
ECO_WANTRETURN. Same as ES_WANTRETURN style.
ECO_SELECTIONBAR. Same as ES_SELECTIONBAR style.
ECO_VERTICAL. Same as ES_VERTICAL style. Available in Asian-language versions only.
Return value

(GET) This message returns a combination of the current option flag values described in the fOptions parameter of the (SET) Options property.

(SET) This message returns the current options of the edit control. Call the (GET) Options property to get the values.


PageRotate

Deprecated. Gets/sets the text layout for a Microsoft Rich Edit control.

(GET) PROPERTY PageRotate () AS DWORD
(SET) PROPERTY PageRotate (BYVAL txtlayout AS LONG)
FUNCTION GetPageRotate () AS DWORD
FUNCTION SetPageRotate (BYVAL txtlayout AS LONG) AS DWORD
ParameterDescription
txtlayoutText layout value. This can be one of the following values.
EPR_0. Text flows from left to right and from top to bottom.
EPR_90. Text flows from bottom to top and from left to right.
EPR_180. Text flows from right to left and from bottom to top.
EPR_270. Text flows from top to bottom and from right to left.
EPR_SE. Windows 8: Text flows top to bottom and left to right (Mongolian text layout).
Return value

(GET) The current text layout. For a list of possible text layout values, see the txtlayout parameter above.

(SET) Return value is the new text layout value. Call the (GET) PageRotate property to get the value.

Remarks

(SET) This message sets the text layout for the entire document. However, embedded contents are not rotated and must be rotated separately by the application.


ParaFormat

Gets/sets the paragraph formatting of the current selection in a rich edit control.

(GET) PROPERTY ParaFormat () AS .PARAFORMAT
(SET) PROPERTY ParaFormat (BYREF pfmt AS .PARAFORMAT)
FUNCTION GetParaFormat () AS .PARAFORMAT
FUNCTION SetParaFormat (BYREF pfmt AS .PARAFORMAT) AS BOOLEAN
ParameterDescription
pfmt(SET) A PARAFORMAT structure specifying the new paragraph formatting attributes. Only the attributes specified by the dwMask member are changed.
Return value

(GET) Returns a PARAFORMAT structure.

(SET) If the operation succeeds, the return value is a nonzero value. If the operation fails, the return value is zero.


PasswordChar

Gets/sets the password character that a rich edit control displays when the user enters text.

(GET) PROPERTY PasswordChar () AS LONG
(SET) PROPERTY PasswordChar (BYVAL dwchar AS DWORD)
FUNCTION GetPasswordChar () AS LONG
FUNCTION SetPasswordChar (BYVAL dwchar AS DWORD)
ParameterDescription
dwchar(SET) The character to be displayed in place of the characters typed by the user. If this parameter is zero, the control removes the current password character and displays the characters typed by the user.
Return value

(GET) The return value specifies the character to be displayed in place of any characters typed by the user. If the return value is NULL, there is no password character, and the control displays the characters typed by the user.

(SET) The set property does not return a value.

Remarks

When an edit control receives the EM_SETPASSWORDCHAR message, the control redraws all visible characters using the character specified by the dwchar parameter. If dwchar is zero, the control redraws all visible characters using the characters typed by the user.

If an edit control is created with the ES_PASSWORD style, the default password character is set to an asterisk (*). If an edit control is created without the ES_PASSWORD style, there is no password character. The ES_PASSWORD style is removed if an EM_SETPASSWORDCHAR is sent with the dwchar parameter set to zero.

Edit controls: Multiline edit controls do not support the password style or messages.


Punctuation

Gets/sets the current punctuation characters for the rich edit control.

(GET) PROPERTY Punctuation (BYVAL punctype AS DWORD) AS .PUNCTUATION
(SET) PROPERTY Punctuation (BYVAL punctype AS LONG, BYREF punct AS .PUNCTUATION)
FUNCTION GetPunctuation (BYVAL punctype AS DWORD) AS .PUNCTUATION
FUNCTION SetPunctuation (BYVAL punctype AS LONG, BYREF punct AS .PUNCTUATION) AS BOOLEAN
ParameterDescription
punctypeSpecifies the punctuation type, which can be one of the following values.
PC_LEADING. Leading punctuation characters.
PC_FOLLOWING. Following punctuation characters.
PC_DELIMITER. Delimiter.
PC_OVERFLOW. Not supported.
punctA PUNCTUATION structure that contains the punctuation characters.
Return value

If the operation succeeds, the return value is a nonzero value. If the operation fails, the return value is zero.

Note

This message is supported only in Asian-language versions of Microsoft Rich Edit 1.0. It is not supported in any later versions.


Rect

Gets/sets the formatting rectangle of a rich edit control.

(GET) PROPERTY Rect () AS .RECT
(SET) PROPERTY Rect (BYVAL fCoord AS LONG, BYREF rc AS .RECT)
FUNCTION GetRect () AS .RECT
SUB SetRect (BYVAL fCoord AS LONG, BYREF rc AS .RECT)
ParameterDescription
fCoord(SET) Rich Edit 2.0 and later: Indicates whether rc specifies absolute or relative coordinates. A value of zero indicates absolute coordinates. A value of 1 indicates offsets relative to the current formatting rectangle. (The offsets can be positive or negative.)
Edit controls and Rich Edit 1.0: This parameter is not used and must be zero.
rc(SET) A RECT structure that specifies the new dimensions of the rectangle. If this parameter is NULL, the formatting rectangle is set to its default values.
Return value

(GET) A RECT structure with the formatting rectangle.

(SET) The set property does not return a value.

Remarks

Setting rc to NULL has no effect if a touch device is installed, or if the message is sent from a thread that has a hook installed (see SetWindowsHookEx). In these cases, rc should contain a valid pointer to a RECT structure.

The (SET) Rect property causes the text of the rich edit control to be redrawn. To change the size of the formatting rectangle without redrawing the text, use the RectNP property.

When a rich edit control is first created, the formatting rectangle is set to a default size. You can use the (SET) Rect message to make the formatting rectangle larger or smaller than the rich edit control window.

If the rich edit control does not have a horizontal scroll bar, and the formatting rectangle is set to be larger than the rich edit control window, lines of text exceeding the width of the rich edit control window (but smaller than the width of the formatting rectangle) are clipped instead of wrapped.

If the rich edit control contains a border, the formatting rectangle is reduced by the size of the border. If you are adjusting the rectangle returned by the (GET) Rect property, you must remove the size of the border before using the rectangle with the (SET) Rect property.

The formatting rectangle does not include the selection bar, which is an unmarked area to the left of each paragraph. When the user clicks in the selection bar, the corresponding line is selected.


RectNP

Sets the formatting rectangle of a multiline rich edit control. It is identical to the Rect property, except that RectNP does not redraw the edit control window.

The formatting rectangle is the limiting rectangle into which the control draws the text. The limiting rectangle is independent of the size of the edit control window.

This message is processed only by multiline edit controls. You can send this message to either an edit control or a rich edit control.

(SET) PROPERTY RectNP (BYVAL fCoord AS LONG, BYREF rc AS .RECT)
SUB SetRectNP (BYVAL fCoord AS LONG, BYREF rc AS .RECT)
ParameterDescription
fCoord(SET) Rich Edit 3.0 and later: Indicates whether prect specifies absolute or relative coordinates. A value of zero indicates absolute coordinates. A value of 1 indicates offsets relative to the current formatting rectangle. (The offsets can be positive or negative.)
rc(SET) A RECT structure that specifies the new dimensions of the rectangle. If this parameter is NULL, the formatting rectangle is set to its default values.
Return value

This property does not return a value.


RedoName

Retrieves the type of the next action, if any, in the control's redo queue.

FUNCTION RedoName () AS LONG
FUNCTION GetRedoName () AS LONG
Return value

If the redo queue for the control is not empty, the value returned is an UNDONAMEID enumeration value that indicates the type of the next action in the control's redo queue.

If there are no redoable actions or the type of the next redoable action is unknown, the return value is zero.

UNDONAMEID enumeration
NameValueDescription
UID_UNKNOWN0The type of undo action is unknown.
UID_TYPING1Typing operation.
UID_DELETE2Delete operation.
UID_DRAGDROP3Drag-and-drop operation.
UID_CUT4Cut operation.
UID_PASTE5Paste operation.
UID_AUTOTABLE6Automatic table insertion; for example, typing +---+---+<Enter> to insert a table row.
Remarks

The types of actions that can be undone or redone include typing, delete, drag-drop, cut, and paste operations. This information can be useful for applications that provide an extended user interface for undo and redo operations, such as a drop-down list box of redoable actions.


ScrollPos

Gets/sets the current scroll position of the edit control.

(GET) PROPERTY ScrollPos () AS .POINT
(SET) PROPERTY ScrollPos (BYREF pt AS .POINT)
FUNCTION GetScrollPos () AS .POINT
FUNCTION SetScrollPos (BYREF pt AS .POINT) AS HRESULT
ParameterDescription
ptA POINT structure which specifies a point in the virtual text space of the document, expressed in pixels. The document will be scrolled until this point is located in the upper-left corner of the edit control window. If you want to change the view such that the upper left corner of the view is two lines down and one character in from the left edge. You would pass a point of (7, 22).
The rich edit control checks the x and y coordinates and adjusts them if necessary, so that a complete line is displayed at the top. It also ensures that the text is never completely scrolled off the view rectangle.
Return value

(GET) A POINT structure containing a point in the virtual text space of the document, expressed in pixels. This point will be the point that is currently located in the upper-left corner of the edit control window.

(SET) This message always returns 1.

Remarks

The values returned in the POINT structure are 16-bit values (even in the 32-bit wide fields).


StoryType

Gets/sets the story type.

PROPERTY StoryType (BYVAL Index AS DWORD) AS DWORD
PROPERTY StoryType (BYVAL Index AS LONG, BYVAL dwType AS DWORD)
FUNCTION GetStoryType (BYVAL Index AS DWORD) AS DWORD
FUNCTION SetStoryType (BYVAL Index AS LONG, BYVAL dwType AS DWORD) AS DWORD
ParameterDescription
Index(GET/SET) The story index.
dwType(SET) The new story type. See the list below.
ConstantValueDescription
tomCommentsStory4The story used for comments.
tomEndnotesStory3The story used for endnotes.
tomEvenPagesFooterStory8The story containing footers for even pages.
tomEvenPagesHeaderStory6The story containing headers for even pages.
tomFindStory128The story used for a Find dialog.
tomFirstPageFooterStory11The story containing the footer for the first page.
tomFirstPageHeaderStory10The story containing the header for the first page.
tomFootnotesStory2The story used for footnotes.
tomMainTextStory1The main story always exists for a rich edit control.
tomPrimaryFooterStory9The story containing footers for odd pages.
tomPrimaryFooterStory7The story containing headers for odd pages.
tomReplaceStory129The story used for a Replace dialog.
tomScratchStory127The scratch story.
tomTextFrameStory5The story used for a text box.
tomUnknownStory0No special type.
Return value

(GET) Returns the story type, which can be a client-defined custom value, or one of the values listed in the table above.

(SET) The story type that was set. Call the (GET) StoryType property to get the value.


Text

Gets/sets the text from a rich edit control.

(GET) PROPERTY Text () AS DWSTRING
(SET) PROPERTY Text (BYREF wszText AS WSTRING)
FUNCTION GetText () AS DWSTRING
FUNCTION SetText (BYREF wszText AS WSTRING) AS BOOLEAN
ParameterDescription
wszTextA WSTRING with the new text.
Return value

(GET) The retrieved text.

(SET) The return value is TRUE if the text is set. Call GetErrorInfo to get information about the result.

Remarks

The Windows API function GetWindowTextW can also be used to retrieve the text of a rich edit control, but it cannot retrieve the text of a control in another application.

Usage example (GET)
DIM dws AS DWSTRING = pRichEdit.Text
Usage example (SET)
DIM dws AS DWSTRING = "New text"
pRichEdit.Text = dws

TextLength

Retrieves the length of all text in a rich edit control.

FUNCTION TextLength () AS LONG
FUNCTION GetTextLength () AS LONG
Return value

The return value is the length of the text in characters, not including the terminating null character.

Remarks

When the GetTextLength method is called, the DefWindowProc function returns the length, in characters, of the text. Under certain conditions, the DefWindowProc function returns a value that is larger than the actual length of the text. This occurs with certain mixtures of ANSI and Unicode, and is due to the system allowing for the possible existence of double-byte character set (DBCS) characters within the text. The return value, however, will always be at least as large as the actual length of the text; you can thus always use it to guide buffer allocation. This behavior can occur when an application uses both ANSI functions and common dialogs, which use Unicode.

To retrieve the text, you can also use the AfxGetWindowText function, the WM_GETTEXT message, or the Windows API GetWindowTextW function.


TextLengthEx

Calculates text length in various ways. It is usually called before creating a buffer to receive the text from the control. Since this CRichEditCtx class uses unicode, it is easier to use the simplified second overloaded function.

FUNCTION TextLengthEx (BYREF gtex AS .GETTEXTLENGTHEX) AS LONG
FUNCTION TextLengthEx (BYVAL dwFlags AS DWORD = GTL_DEFAULT) AS LONG
FUNCTION GetTextLengthEx OVERLOAD (BYREF gtex AS .GETTEXTLENGTHEX) AS LONG
FUNCTION GetTextLengthEx OVERLOAD (BYVAL dwFlags AS DWORD = GTL_DEFAULT) AS LONG
ParameterDescription
gtexA GETTEXTLENGTHEX structure that receives the text length information.
dwFlagsValue specifying the method to be used in determining the text length. This member can be one or more of the following values (some values are mutually exclusive).
FlagMeaning
GTL_DEFAULTReturns the number of characters. This is the default.
GTL_USECRLFComputes the answer by using CR/LFs at the end of paragraphs.
GTL_PRECISEComputes a precise answer. This approach could necessitate a conversion and thereby take longer. This flag cannot be used with the GTL_CLOSE flag. E_INVALIDARG will be returned if both are used.
GTL_CLOSEComputes an approximate (close) answer. It is obtained quickly and can be used to set the buffer size. This flag cannot be used with the GTL_PRECISE flag. E_INVALIDARG will be returned if both are used.
GTL_NUMCHARSReturns the number of characters. This flag cannot be used with the GTL_NUMBYTES flag. E_INVALIDARG will be returned if both are used.
GTL_NUMBYTESReturns the number of bytes. This flag cannot be used with the GTL_NUMCHARS flag. E_INVALIDARG will be returned if both are used
Return value

First overloaded method: The method returns the number of characters in the edit control, depending on the setting of the flags in the GETTEXTLENGTHEX structure. If incompatible flags were set in the flags member, the message returns E_INVALIDARG.

Second overloaded method: The method returns the number of characters in the edit control, depending on the setting of the flags in the dwFlags parameter. If incompatible flags were set in the flags member, the message returns E_INVALIDARG.

Remarks

This message is a fast and easy way to determine the number of characters in the Unicode version of the rich edit control. However, for a non-Unicode target code page you will potentially be converting to a combination of single-byte and double-byte characters.

Usage examples
--- First overloaded method:
DIM gtex AS GETTEXTLENGTHEX = TYPE<GETTEXTLENGTHEX>(GTL_NUMCHARS, 1200)
DIM Result AS LONG = pRichEdit.GetTextLEngthEx(gtex)
DIM cbLen AS LONG
IF Result <> E_INVALIDARG THEN cbLen = Result
--- Second overloaded method:
DIM Result AS LONG = pRichEdit.GetTextLEngthEx                 ' // Uses the GTL_DEFAULT flag
DIM Result AS LONG = pRichEdit.GetTextLEngthEx(GTL_NUMCHARS)   ' // Uses the GTL_NUMCHARS flag
DIM cbLen AS LONG
IF Result <> E_INVALIDARG THEN cbLen = Result

TextMode

Gets/sets the current text mode and undo level of a rich edit control.

(GET) PROPERTY TextMode () AS DWORD
(SET) PROPERTY TextMode (BYVAL values AS LONG)
FUNCTION GetTextMode () AS DWORD
FUNCTION SetTextMode (BYVAL values AS LONG) AS BOOLEAN
ParameterDescription
valuesOne or more values from the TEXTMODE enumeration type. The values specify the new settings for the control's text mode and undo level parameters.
TextMode enumeration type

Specify one of the following values to set the text mode parameter. If you do not specify a text mode value, the text mode remains at its current setting.

ValueMeaning
TM_PLAINTEXTIndicates plain text mode, in which the control is similar to a standard edit control. For more information about plain text mode, see the Remarks section.
TM_RICHTEXTIndicates rich text mode, in which the control has standard rich edit functionality. Rich text mode is the default setting.

Specify one of the following values to set the undo level parameter. If you do not specify an undo level value, the undo level remains at its current setting.

ValueMeaning
TM_SINGLELEVELUNDOThe control allows the user to undo only the last action that can be undone.
TM_MULTILEVELUNDOThe control supports multiple undo operations. This is the default setting. Use the RichEdit_SetUndoLimit message to set the maximum number of undo actions.

Specify one of the following values to set the code page parameter. If you do not specify an code page value, the code page remains at its current setting.

ValueMeaning
TM_SINGLECODEPAGEThe control only allows the English keyboard and a keyboard corresponding to the default character set. For example, you could have Greek and English. Note that this prevents Unicode text from entering the control. For example, use this value if a Rich Edit control must be restricted to ANSI text.
TM_MULTICODEPAGEThe control allows multiple code pages and Unicode text into the control. This is the default setting.
Return value

(GET) The return value is one or more values from the TEXTMODE enumeration type. The values indicate the current text mode and undo level of the control.

(SET) If the message succeeds, the result code is zero. If the message fails, the result code is a nonzero value.

Remarks

In rich text mode, a rich edit control has standard rich edit functionality. However, in plain text mode, the control is similar to a standard edit control:

  • The text in a plain text control can have only one format (such as Bold, 10pt Arial).
  • The user cannot paste rich text formats, such as Rich Text Format (RTF) or embedded objects into a plain text control.
  • Rich text mode controls always have a default end-of-document marker or carriage return, to format paragraphs. Plain text controls, on the other hand, do not need the default, end-of-document marker, so it is omitted.
  • The control must contain no text when it receives the EM_SETTEXTMODE message. To ensure there is no text, call the (SET) Text property with an empty string ("").

TouchOptions

Gets/sets the touch options that are associated with a rich edit control.

(GET) PROPERTY TouchOptions (BYVAL opt AS LONG PTR) AS DWORD
(SET) PROPERTY TouchOptions (BYVAL opt AS LONG, BYVAL fEnable AS LONG)
FUNCTION GetTouchOptions (BYVAL opt AS LONG PTR) AS DWORD
FUNCTION SetTouchOptions (BYVAL opt AS LONG, BYVAL fEnable AS LONG) AS HRESULT
ParameterDescription
opt(GET/SET) The touch options to set. It can be one of the following values:
RTO_SHOWHANDLES. Show or hide the touch gripper handles, depending on the value of opt.
RTO_DISABLEHANDLES. Enable or disable the touch gripper handles, depending on the value of opt. When handles are disabled, they are hidden if they are visible and remain hidden until TouchOptions changes their status.
fEnable(SET) Set to TRUE to show/enable the touch selection handles, or FALSE to hide/disable the touch selection handles.
Return value

(GET) Returns the value of the option specified by the opt parameter. It is nonzero if opt is RTO_SHOWHANDLES and the touch grippers are visible; zero, otherwise.

(SET) Returns TRUE if opt is valid, otherwise FALSE.

Remarks

Advanced line breaking is turned on automatically by the rich edit control when needed, such as for handling complex scripts like Arabic and Hebrew, and for mathematics. It s also needed for justified paragraphs, hyphenation, and other typographic features.


TypographyOptions

Gets/sets the current state of the typography options of a rich edit control.

(GET) PROPERTY TypographyOptions () AS DWORD
(SET) PROPERTY TypographyOptions (BYVAL pto AS LONG, BYVAL fMask AS LONG)
FUNCTION GetTypographyOptions () AS DWORD
FUNCTION SetTypographyOptions (BYVAL pto AS LONG, BYVAL fMask AS LONG) AS BOOLEAN
ParameterDescription
ptoSpecifies one or both of the following values.
TO_ADVANCEDTYPOGRAPHY. Advanced line breaking and line formatting is turned on.
TO_SIMPLELINEBREAK. Faster line breaking for simple text (requires TO_ADVANCEDTYPOGRAPHY).
fMaskA mask consisting of one or more of the flags in pto. Only the flags that are set in this mask will be set or cleared. This allows a single flag to be set or cleared without reading the current flag states.
Return value

(GET) Returns the current typography options.

(SET) A boolean true (-1) or false (0).

Remarks

You can turn on advanced line breaking by sending calling the (SET) TypographyOPtions property. Advanced line breaking is turned on automatically by the rich edit control when needed, such as for handling complex scripts like Arabic and Hebrew, and for mathematics. It is also needed for justified paragraphs, hyphenation, and other typographic features.


EnableAdvancedTypography

Enables advanced typography.

FUNCTION EnableAdvancedTypography () AS BOOLEAN
Return value

A boolean true (-1) or false (0).

Remarks

Advanced typography is needed for justified paragraphs, hyphenation, and other typographic features. Advanced line breaking is turned on automatically by the rich edit control when needed, such as for handling complex scripts like Arabic and Hebrew, and for mathematics.


WordBreakProc

Gets/sets the address of the currently registered word-break procedure.

PROPERTY WordBreakProc () AS LONG_PTR
PROPERTY WordBreakProc (BYVAL pfn AS LONG_PTR)
FUNCTION GetWordBreakProc () AS LONG_PTR
SUB SetWordBreakProc (BYVAL pfn AS LONG_PTR)

Gets/sets the address of the currently registered extended word-break procedure.

PROPERTY WordBreakProcEx () AS LONG_PTR
PROPERTY WordBreakProcEx (BYVAL pfn AS LONG_PTR)
FUNCTION GetWordBreakProcEx () AS LONG_PTR
SUB SetWordBreakProcEx (BYVAL pfn AS LONG_PTR)
ParameterDescription
pfnPointer to an EditWordBreakProcEx function, or NULL to use the default procedure.
Return value

The return value specifies the address of the application-defined word-break function. The return value is NULL if no word-break function exists.

Remarks

A Wordwrap function scans a text buffer that contains text to be sent to the display, looking for the first word that does not fit on the current display line. The wordwrap function places this word at the beginning of the next line on the display. A Wordwrap function defines the point at which the system should break a line of text for multiline edit controls, usually at a space character that separates two words.


WordWrap

Enables/disables word wrap.

FUNCTION DisableWordWrap (BYVAL LineWidth AS LONG = 32767) AS BOOLEAN
FUNCTION EnableWordWrap () AS BOOLEAN
ParameterDescription
LineWidthThe line width. Default value: 32767 characters.
Return value

If the method succeeds it returns the boolean value true (-1); if it fails, it returns false (0).


WordWrapMode

Gets/sets the current word wrap and word-break options for the rich edit control.

(GET) PROPERTY WordWrapMode () AS DWORD
(SET) PROPERTY WordWrapMode (BYVAL values AS DWORD) AS DWORD
FUNCTION GetWordWrapMode () AS DWORD
FUNCTION SetWordWrapMode (BYVAL values AS LONG) AS LONG
ParameterDescription
valuesSpecifies one or more of the following values.
ValueMeaning
WBF_WORDWRAPEnables Asian-specific word wrap operations, such as kinsoku in Japanese.
WBF_WORDBREAKEnables English word-breaking operations in Japanese and Chinese. Enables Hangeul word-breaking operation.
WBF_OVERFLOWRecognizes overflow punctuation. (Not currently supported.)
WBF_LEVEL1Sets the Level 1 punctuation table as the default.
WBF_LEVEL2Sets the Level 2 punctuation table as the default.
WBF_CUSTOMSets the application-defined punctuation table.
Return value

(GET) The the current word wrap and word-break options.

(SET) This method returns the current word-wrapping and word-breaking options.

Remarks

This property is supported only in Asian-language versions of Microsoft Rich Edit 1.0. It is not supported in any later versions of Rich Edit. This message must not be sent by the application-defined, word-break procedure.


CallAutocorrectProc

Calls the autocorrect callback function that is stored by the (SET) AutocorrectProc property, provided that the text preceding the insertion point is a candidate for autocorrection.

FUNCTION CallAutocorrectProc (BYVAL char AS WCHAR) AS LONG
ParameterDescription
charA character of type WCHAR. If this character is a tab (U+0009), and the character preceding the insertion point isn't a tab, then the character preceding the insertion point is treated as part of the autocorrect candidate string instead of as a string delimiter; otherwise, it has no effect.
Return value

The return value is zero if the message succeeds, or nonzero if an error occurs.


CanPaste

Determines whether a rich edit control can paste a specified clipboard format.

FUNCTION CanPaste (BYVAL clipformat AS LONG) AS BOOLEAN
ParameterDescription
clipformatSpecifies the Clipboard Formats to try. To try any format currently on the clipboard, set this parameter to zero.
Return value

If the clipboard format can be pasted, the return value is a nonzero value. If the clipboard format cannot be pasted, the return value is zero.


CanRedo

Determines whether there are any actions in the control redo queue.

FUNCTION CanRedo () AS BOOLEAN
Return value

If there are actions in the control redo queue, the return value is a nonzero value. If the redo queue is empty, the return value is zero.

CanUndo

Determines whether there are any actions in an edit control's undo queue.

FUNCTION CanUndo () AS BOOLEAN
Return value

If there are actions in the control's undo queue, the return value is nonzero. If the undo queue is empty, the return value is zero.


DisplayBand

Displays a portion of the contents of a rich edit control, as previously formatted for a device using the FormatRange method.

FUNCTION DisplayBand (BYREF rc AS .RECT) AS BOOLEAN
ParameterDescription
rcA RECT structure specifying the display area of the device.
Return value

If the operation succeeds, the return value is TRUE. If the operation fails, the return value is FALSE.

Remarks

Text and Component Object Model (COM) objects are clipped by the rectangle. The application does not need to set the clipping region.

Banding is the process by which a single page of output is generated using one or more separate rectangles, or bands. When all bands are placed on the page, a complete image results. This approach is often used by raster printers that do not have sufficient memory or ability to image a full page at one time. Banding devices include most dot matrix printers as well as some laser printers.


EmptyUndoBuffer

Resets the undo flag of a rich edit control. The undo flag is set whenever an operation within the rich edit control can be undone.

SUB EmptyUndoBuffer ()
Return value

This method does not return a value.

Remarks

The undo flag is automatically reset whenever the edit control receives a WM_SETTEXT or EM_SETHANDLE message.


ExGetSel

Oveloaded method to retrieve the starting and ending character positions of the selection in a rich edit control.

FUNCTION ExGetSel OVERLOAD () AS CHARRANGE
FUNCTION ExGetSel OVERLOAD (BYREF cpMin AS LONG, BYVAL cpMax AS LONG)
ParameterDescription
cpMinCharacter position index immediately preceding the first character in the range.
cpMazCharacter position immediately following the last character in the range.
Return value

The first overloaded method returns a CHARRANGE structure with the selection range.

The second overloaded method does not return a value. The values are filled in the passed parameters.

CHARRANGE structure
type _charrange field = 4
   cpMin as LONG
   cpMax as LONG
end type

type CHARRANGE as _charrange
MemberDescription
cpMinCharacter position index immediately preceding the first character in the range.
cpMaxCharacter position immediately following the last character in the range.

ExLimitText

Sets an upper limit to the amount of text the user can type or paste into a rich edit control.

SUB ExLimitText (BYVAL dwLimit AS DWORD)
ParameterDescription
dwLimitSpecifies the maximum amount of text that can be entered. If this parameter is zero, the default maximum is used, which is 64K characters. If this parameter is -1 (&hFFFFFFFF), raises the the 32,767 default characters limit to no limit. A COM object counts as a single character.
Remarks

The text limit set by the ExLimitText method does not limit the amount of text that you can stream into a rich edit control using the StreamIn method with the pedst parameter set to SF_TEXT. However, it does limit the amount of text that you can stream into a rich edit control using the StreamIn method with the pedst parameter set set to SF_RTF.

Before ExLimitText is called, the default limit to the amount of text a user can enter is 32,767 characters.

Return value

This method does not return a value.


ExLineFromChar

Determines which line contains the specified character in a rich edit control.

FUNCTION ExLineFromChar (BYVAL iIndex AS LONG) AS LONG
ParameterDescription
iIndexZero-based index of the character.
Return value

Returns the zero-based index of the line.


ExSetSel

Overloaded method that selects a range of characters and/or Component Object Model (COM) objects in a Microsoft Rich Edit control.

FUNCTION ExSetSel OVERLOAD (BYREF cr AS CHARRANGE) AS DWORD
SUB ExSetSel OVERLOAD (BYVAL cpMin AS LONG = 0, BYVAL cpMax AS LONG = -1)
ParameterDescription
crA CHARRANGE structure that specifies the selection range.
ParameterDescription
cpMinCharacter position index immediately preceding the first character in the range.
cpMaxCharacter position immediately following the last character in the range.
CHARRANGE structure
type _charrange field = 4
   pMin as LONG
   cpMax as LONG
end type

type CHARRANGE as _charrange
MemberDescription
cpMinCharacter position index immediately preceding the first character in the range.
cpMaxCharacter position immediately following the last character in the range.
Return value

The return value is the selection that is actually set.

Usage example
DIM chrRange AS CHARRANGE = TYPE<CHARRANGE>(3, 12)
pRichEditCtro.ExSetSel(@chrRange)

FindText

Overloaded method to find text within a rich edit control.

FUNCTION FindText OVERLOAD (BYVAL fOptions AS DWORD, BYREF ft AS FINDTEXTW) AS LONG
FUNCTION FindText OVERLOAD (BYVAL fOptions AS DWORD = FR_DOWN, BYVAL cpMin AS LONG = 0, _
   BYVAL cpMax AS LONG = -1, BYREF wszText AS WSTRING) AS LONG
ParameterDescription
fOptionsSpecifies the parameters of the search operation. This parameter can be one or more of the following values.
FR_DOWN. If set, the operation searches from the end of the current selection to the end of the document. If not set, the operation searches from the end of the current selection to the beginning of the document.
FR_MATCHALEFHAMZA. By default, Arabic and Hebrew alefs with different accents are all matched by the alef character. Set this flag if you want the search to differentiate between alefs with different accents.
FR_MATCHCASE. If set, the search operation is case-sensitive. If not set, the search operation is case-insensitive.
FR_MATCHDIAC. By default, Arabic and Hebrew diacritical marks are ignored. Set this flag if you want the search operation to consider diacritical marks.
FR_MATCHKASHIDA. By default, Arabic and Hebrew kashidas are ignored. Set this flag if you want the search operation to consider kashidas.
FR_WHOLEWORD. If set, the operation searches only for whole words that match the search string. If not set, the operation also searches for word fragments that match the search string.
ftA FINDTEXTW structure containing information about the find operation.
cpMinCharacter position index immediately preceding the first character in the range.
cpMaxCharacter position immediately following the last character in the range. If the cpMin and cpMax members are equal, the range is empty. The range includes everything if cpMin is 0 and cpMax is –1.
pwszTextA WSTRING containing the text to find.
Return value

If the target string is found, the return value is the zero-based position of the first character of the match. If the target is not found, the return value is -1.

Search in a range:

DIM dws AS DWSTRING = "box"
DIM cbStart AS LONG = pRichEdit.FindText(FR_DOWN, 5, 20, cws)
pRichEdit.ExSetSel(cbStart, cbStart + LEN(dws))

Search in the entire document:

DIM dws AS DWSTRING = "box"
DIM cbStart AS LONG = pRichEdit.FindText(FR_DOWN, 0, -1, dws)
--or--
DIM cbStart AS LONG = pRichEdit.FindText(FR_DOWN, , , dws)
pRichEdit.ExSetSel(cbStart, cbStart + LEN(cws))

Case sensitive search:

DIM wws AS DWSTRING = "box"
DIM cbStart AS LONG = pRichEdit.FindText(FR_DOWN OR FR_MATCHCASE, 5, 20, cws)
pRichEdit.ExSetSel(cbStart, cbStart + LEN(wws))

Search backwards from the end of the document to the beginning:

DIM cbStart AS LONG = pRichEdit.GetTextLength
DIM cbStart AS LONG = pRichEdit.FindText(0, cbStart, 0, cws)
pRichEdit.ExSetSel(cbStart, cbStart + LEN(cws))

FindTextEx

Overloaded method to find text within a rich edit control.

FUNCTION FindTextEx OVERLOAD (BYVAL fOptions AS DWORD, BYREF ftexw AS FINDTEXTEXW) AS LONG
FUNCTION FindTextEx OVERLOAD (BYVAL fOptions AS DWORD = FR_DOWN, BYVAL cpMin AS LONG = 0, _
   BYVAL cpMax AS LONG = -1, BYREF wszText AS WSTRING) AS CHARRANGE
ParameterDescription
fOptionsSpecifies the parameters of the search operation. This parameter can be one or more of the following values.
FR_DOWN. If set, the operation searches from the end of the current selection to the end of the document. If not set, the operation searches from the end of the current selection to the beginning of the document.
FR_MATCHALEFHAMZA. By default, Arabic and Hebrew alefs with different accents are all matched by the alef character. Set this flag if you want the search to differentiate between alefs with different accents.
FR_MATCHCASE. If set, the search operation is case-sensitive. If not set, the search operation is case-insensitive.
FR_MATCHDIAC. By default, Arabic and Hebrew diacritical marks are ignored. Set this flag if you want the search operation to consider diacritical marks.
FR_MATCHKASHIDA. By default, Arabic and Hebrew kashidas are ignored. Set this flag if you want the search operation to consider kashidas.
FR_WHOLEWORD. If set, the operation searches only for whole words that match the search string. If not set, the operation also searches for word fragments that match the search string.
ftexwA FINDTEXTEXW structure containing information about the find operation.
cpMinCharacter position index immediately preceding the first character in the range.
cpMaxCharacter position immediately following the last character in the range. If the cpMin and cpMax members are equal, the range is empty. The range includes everything if cpMin is 0 and cpMax is –1.
pwszTextA WSTRING containing the text to find.
Return value

First overloaded function: If the target string is found, the return value is the zero-based position of the first character of the match. If the target is not found, the return value is -1.

Second overloaded function: A CHARRANGE structure. The range of characters in which the text was found. If the text was not found, cpMin and cpMax are -1.

Remarks

FindTextEx uses the FINDTEXTEXW structure, while FindTex uses the FINDTEXTW structure. The difference is that FindTextEx reports the range of text that was found.

Usage examples

Search in a range:

DIM dws AS DWSTRING =  "box"
DIM chrg AS CHARRANGE = pRichEdit.FindTextEx(FR_DOWN, 5, 20, dws)
pRichEdit.ExSetSel(chrg.cpMin, chrg.cpMax)

Search in the entire document:

DIM dws AS DWSTRING =  "box"
DIM chrg AS CHARRANGE = pRichEdit.FindTextEx(FR_DOWN, 0, -1, dws)
--or--
DIM chrg AS CHARRANGE = pRichEdit.FindTextEx(FR_DOWN, , , dws)
pRichEdit.ExSetSel(chrg.cpMin, chrg.cpMax)

Search backwards from the end of the document to the beginning:

DIM cbStart AS LONG = pRichEdit.GetTextLength
DIM chrg AS CHARRANGE = pRichEdit.FindTextEx(0, cbStart, 0, dws)
pRichEdit.ExSetSel(chrg.cpMin, chrg.cpMax)

FindWordBreak

Finds the next word break before or after the specified character position or retrieves information about the character at that position.

FUNCTION FindWordBreak (BYVAL fOperation AS DWORD, BYVAL dwStartPos AS DWORD) AS DWORD
ParameterDescription
fOperationSpecifies the find operation. This parameter can be one of the following values.
WB_CLASSIFY. Returns the character class and word-break flags of the character at the specified position.
WB_ISDELIMITER. Returns TRUE if the character at the specified position is a delimiter, or FALSE otherwise.
WB_LEFT. Finds the nearest character before the specified position that begins a word.
WB_LEFTBREAK. Finds the next word end before the specified position. This value is the same as WB_PREVBREAK.
WB_MOVEWORDLEFT. Finds the next character that begins a word before the specified position. This value is used during CTRL+LEFT ARROW key processing. This value is the similar to WB_MOVEWORDPREV. See Remarks for more information.
WB_MOVEWORDRIGHT. Finds the next character that begins a word after the specified position. This value is used during CTRL+right key processing. This value is similar to WB_MOVEWORDNEXT. See Remarks for more information.
WB_RIGHT. Finds the next character that begins a word after the specified position.
WB_RIGHTBREAK. Finds the next end-of-word delimiter after the specified position. This value is the same as WB_NEXTBREAK.
dwStartPosZero-based character starting position.
Return value

The method returns a value based on the fOperation parameter.

Return codeDescription
WB_CLASSIFYReturns the character class and word-break flags of the character at the specified position.
WB_ISDELIMITERReturns TRUE if the character at the specified position is a delimiter; otherwise it returns FALSE.
OthersReturns the character index of the word break.
Remarks

If fOperation is WB_LEFT and WB_RIGHT, the word-break procedure finds word breaks only after delimiters. This matches the functionality of an edit control. If fOperation is WB_MOVEWORDLEFT or WB_MOVEWORDRIGHT, the word-break procedure also compares character classes and word-break flags.

For information about character classes and word-break flags, see Word and Line Breaks.


FormatRange

Formats a range of text in a rich edit control for a specific device.

FUNCTION FormatRange (BYVAL fRender AS LONG, BYREF fr AS FORMATRANGE) AS DWORD
ParameterDescription
fRenderSpecifies whether to render the text. If this parameter is not zero, the text is rendered. Otherwise, the text is just measured.
frA FORMATRANGE structure containing information about the output device, or NULL to free information cached by the control.
Return value

This method returns the index of the last character that fits in the region, plus 1.

Remarks

This method is typically used to format the content of rich edit control for an output device such as a printer.

After using this method to format a range of text, it is important that you free cached information by sending FormatRange again, but with fr set to NULL; otherwise, a memory leak will occur. Also, after using this message for one device, you must free cached information before using it again for a different device.


GetCharFromPos

Gets information about the character closest to a specified point in the client area of an edit control.

FUNCTION GetCharFromPos (BYREF ptl AS .POINTL) AS LONG
ParameterDescription
ptlA POINTL structure that contains the horizontal and vertical coordinates of a point in the control's client area. The coordinates are in screen units and are relative to the upper-left corner of the control's client area.
Return value

The return value specifies the zero-based character index of the character nearest the specified point. The return value indicates the last character in the edit control if the specified point is beyond the last character in the control.


GetIMEColor

Gets the Input Method Editor (IME) composition color. This message is available only in Asian-language versions of the operating system.

FUNCTION GetIMEColor (BYVAL rgCmpclr AS .COMPCOLOR PTR) AS LONG
   RETURN this.SetResult(SendMessageW(m_hRichEdit, EM_GETIMECOLOR, 0, cast(LPARAM, rgCmpclr)))
END FUNCTION
ParameterDescription
rgCmpclrA pointer to a four-element array of COMPCOLOR structures.
Return value

If the operation succeeds, the return value is a nonzero value. If the operation fails, the return value is zero. Call GetErrorInfo to get information about the result.

Note

This message is supported only in Asian-language versions of Microsoft Rich Edit 1.0. It is not supported in any later versions.


GetIMECompMode

Gets the current IME mode for a rich edit control.

FUNCTION GetIMECompMode () AS DWORD
Return value

The return value is one of the following values.

Return codeDescription
ICM_NOTOPENIME is not open.
ICM_LEVEL3True inline mode.
ICM_LEVEL2Level 2.
ICM_LEVEL2_5Level 2.5.
ICM_LEVEL2_SUISpecial UI.

GetIMECompText

Gets the Input Method Editor (IME) composition text.

FUNCTION GetIMECompText (BYREF ict AS .IMECOMPTEXT, BYVAL buffer AS ANY PTR) AS DWORD
ParameterDescription
ictA IMECOMPTEXT structure.
bufferThe buffer that receives the composition text. The size of this buffer is contained in the cb member of the IMECOMPTEXT structure.
Return value

If successful, the return value is the number of Unicode characters copied to the buffer. Otherwise, it is zero.

Remarks

This message only takes Unicode strings.

Security Warning: Be sure to have a buffer sufficient for the size of the input. Failure to do so could cause problems for your application.


GetIMEProperty

Gets the property and capabilities of the Input Method Editor (IME) associated with the current input locale.

FUNCTION GetIMEProperty (BYVAL figp AS DWORD) AS DWORD
ParameterDescription
figpSpecifies the type of property information to retrieve. This parameter can be one of the following values.
ValueMeaning
IGP_PROPERTYProperty information.
IGP_CONVERSIONConversion capabilities.
IGP_SENTENCESentence mode capabilities.
IGP_UIUser interface capabilities.
IGP_SETCOMPSTRComposition string capabilities.
IGP_SELECTSelection inheritance capabilities.
IGP_GETIMEVERSIONRetrieves the system version number for which the specified IME was created.
Return value

Returns the property or capability value, depending on the value of the figp parameter.

Remarks

If figp is IGP_PROPERTY, it returns one or more of the following values.

RequirementMeaning
IME_PROP_AT_CARETIf set, conversion window is at the caret position. If clear, the window is near caret position.
IME_PROP_SPECIAL_UIIf set, IME has a nonstandard user interface. The application should not draw in the IME window.
IME_PROP_CANDLIST_START_FROM_1If set, strings in the candidate list are numbered starting at 1. If clear, strings start at zero.
IME_PROP_UNICODEIf set, the IME is viewed as a UnicodeIME. The system and the IME will communicate through the UnicodeIME interface. If clear, IME will use the ANSI interface to communicate with the system.
IME_PROP_COMPLETE_ON_UNSELECTIf set, conversion window is at the caret position. If clear, the window is near caret position.
IME_PROP_ACCEPT_WIDE_VKEYIf set, the IME processes the injected Unicode that came from the SendInput function by using VK_PACKET. If clear, the IME might not process the injected Unicode, and the injected Unicode might be sent to the application directly.

If figp is IGP_UI, it returns one or more of the following values.

RequirementMeaning
UI_CAP_2700Supports text escapement values of 0 or 2700. For more information, see lfEscapement.
UI_CAP_ROT90Supports text escapement values of 0, 900, 1800, or 2700. For more information, see lfEscapement.
UI_CAP_ROTANYSupports any text escapement value. For more information, see lfEscapement.

If figp is IGP_SETCOMPSTR, it returns one or more of the following values.

RequirementMeaning
SCS_CAP_COMPSTRCan create the composition string by calling the ImmSetCompositionString function with the SCS_SETSTR value.
SCS_CAP_MAKEREADCan create the reading string from corresponding composition string when using the ImmSetCompositionString function with SCS_SETSTR and without setting lpRead.
SCS_CAP_SETRECONVERTSTRINGThis IME can support reconversion. Use ImmSetCompositionString to do the reconversion.

If figp is IGP_SELECT, it returns one or more of the following values.

RequirementMeaning
SELECT_CAP_CONVMODEInherits conversion mode when a new IME is selected.
SELECT_CAP_SENTENCEInherits sentence mode when a new IME is selected.

If figp is IGP_GETIMEVERSION, it returns one or more of the following values.

RequirementMeaning
IMEVER_0310The IME was created for Windows 3.1.
IMEVER_0400The IME was created for Windows 95 or later.

This message is similar to ImmGetProperty, except that it uses the current input locale. The application should call IsIME method before calling this function.


GetLine

Copies a line of text from a rich edit control.

FUNCTION GetLine (BYVAL which AS DWORD) AS DWSTRING
ParameterDescription
whichThe zero-based index of the line to retrieve from a multiline edit control. A value of zero specifies the topmost line.
Return value

A copy of the line.


GetLineCount

Gets the number of lines in a multiline rich edit control.

FUNCTION GetLineCount () AS LONG
Return value

The return value is an integer specifying the total number of text lines in the multiline edit control or rich edit control. If the control has no text, the return value is 1. The return value will never be less than 1.

Remarks

The GetLineCount method retrieves the total number of text lines, not just the number of lines that are currently visible.

If the Wordwrap feature is enabled, the number of lines can change when the dimensions of the editing window change.


GetOleInterface

Retrieves an IRichEditOle object that a client can use to access a rich edit control's Component Object Model (COM) functionality.

FUNCTION GetOleInterface () AS IRichEditOle PTR
Return value

A pointer to the IRichEditOle interface. The control calls the AddRef method for the object before returning, so the calling application must call the Release method when it is done with the object. |


GetSel

Gets the starting and ending character positions of the current selection in a rich edit control.

FUNCTION GetSel OVERLOAD (BYREF dwStartPos AS DWORD, BYREF dwEndPos AS DWORD) AS LONG
FUNCTION GetSel OVERLOAD () AS .POINTL
ParameterDescription
dwStartPosA DWORD variable that receives the starting position of the selection. This parameter can be NULL.
dwEndPosA DWORD variable that receives the position of the first unselected character after the end of the selection. This parameter can be NULL.
Return value

The return value is a zero-based value with the starting position of the selection in the LOWORD and the position of the first character after the last selected character in the HIWORD. If either of these values exceeds 65,535, the return value is -1. It is better to use the values returned in dwStartPos and dwEndPos because they are full 32-bit values.

The second overloaded method returns a POINTL structure. The x and y members of this structure receive the starting and ending positions of the selection.

Remarks

If there is no selection, the starting and ending values are both the position of the caret.

You can also use the ExtGetSel method to retrieve the same information. ExtGetSel also returns starting and ending character positions as 32-bit values. A combination of the use of ExtGetSel and GetSelText are used in the GetSelText method to retrieve the selected text as a DWSTRING.


GetSelText

Retrieves the currently selected text in a rich edit control.

FUNCTION GetSelText () AS DWSTRING
Return value

The selected text as a DWSTRING (dynamic unicode string).

GetTableParams

Retrieves the table parameters for a table row and the cell parameters for the specified number of cells.

FUNCTION GetTableParams (BYREF tp AS TABLEROWPARMS, BYREF tcp AS TABLECELLPARMS) AS DWORD
ParameterDescription
tpA TABLEROWPARMS structure.
tcpA TABLECELLPARMS structure.
Return value

Returns S_OK if successful, or one of the following error codes.

Return codeDescription
E_FAILChanges cannot be made. This can occur if the control is a plain-text or single-line control, or if the insertion point is inside a math object. It also occurs if tables are disabled if the EditStyleEx property sets the SES_EX_NOTABLE value.
E_INVALIDARGThe lptp or lptcp parameters are NULL or point to an invalid structure. The cbRow member of the TABLEROWPARMS structure must equal sizeof(TABLEROWPARMS) or sizeof(TABLEROWPARMS) 2*sizeof(long). The latter value is the size of the RichEdit 4.1 TABLEROWPARMS structure. The cbCell member of the TABLEROWPARMS structure must equal sizeof(TABLECELLPARMS). The query character position must be at a table row delimiter.
E_OUTOFMEMORYInsufficient memory is available.
Remarks

This method gets the table parameters for the row at the character position specified by the cpStartRow member of the TABLEROWPARMS structure, and the number of cells specified by the cCells member of the TABLECELLPARMS structure.

The character position specified by the cpStartRow member of the TABLEROWPARMS structure should be at the start of the table row, or at the end delimiter of the table row. If cpStartRow is set to 1, the character position is given by the current selection. In this case, position the selection at the end of the row (between the cell mark and the end delimiter of the table row), or select the row.


GetRawText

Gets the raw text exactly as it appears in memory.

FUNCTION GetRawText () AS STRING
Return value

The retrieved text.

Remarks

Text is retrieved exactly as it appears in memory. This includes special structure characters for table row and cell delimiters as well as math object delimiters (start delimiter U+FDD0, argument delimiter U+FDEE, and end delimiter U+FDDF) and object markers (U+FFFC). This maintains character-position alignment between the retrieved text and the text in memory.


GetRawTextLength

Gets the length of the raw text.

FUNCTION GetRawTextLength () AS LONG
Return value

The retrieved length.


SaveRawText

Saves the raw contents of the rich edit control to a file.

FUNCTION SaveRawText (BYREF wszFilename AS WSTRING, BYVAL Overwrite AS BOOLEAN = FALSE, _
   BYVAL dwFlagsAndAttributes AS DWORD = FILE_ATTRIBUTE_NORMAL) AS BOOLEAN
ParameterDescription
wszFilenamePath and file name of the file where the RTF content will be saved.
OverwriteIf true, the file will be overwritten if it already exists and the function will return true; if false, the file will not be overwritten, the function will return false and GetLastResult" will return the **ERROR_ALREADY_EXISTS error.
dwFlagsAndAttributesThe file or device attributes and flags. Default is FILE_ATTRIBUTE_NORMAL, which is the most common default value for files. To see more options see CreateFileW
Return value

A bollean true (-1) of false (0).

Usage example
RichEdit->SaveRawText(AfxGetExePath & "\test.txt", TRUE)

GetTextEx

Gets all of the text from the rich edit control in any particular code base you want.

FUNCTION GetTextEx (BYREF gtex AS GETTEXTEX, BYVAL buffer AS ANY PTR) AS DWORD
ParameterDescription
gtexA GETTEXTEX structure which indicates how to translate the text before putting it into the output buffer.
bufferPointer to the buffer to receive the text. The size of this buffer, in bytes, is specified by the cb member of the GETTEXTEX structure. Use the GetTextLength method to get the required size of the buffer.
Return value

The return value is the number of characters copied into the output buffer, not including the null terminator.

Remarks

If the size of the output buffer is less than the size of the text in the control, the edit control will copy text from its beginning and place it in the buffer until the buffer is full. A terminating null character will still be placed at the end of the buffer.


GetTextRange

Overloaded method that retrieves a specified range of characters from a rich edit control.

FUNCTION GetTextRange (BYREF trg AS .TEXTRANGEW) AS DWORD
FUNCTION GetTextRange (BYVAL cpMin AS LONG = 0, BYVAL cpMax AS LONG = -1) AS DWSTRING
ParameterDescription
trgA TEXTRANGEW structure that specifies the range of characters to retrieve and a buffer to copy the characters to.
ParameterDescription
cpMinCharacter position index immediately preceding the first character in the range.
cpMaxCharacter position immediately following the last character in the range. If the cpMin and cpMax members are equal, the range is empty. The range includes everything if cpMin is 0 and cpMax is –1.
Return value

The first overloaded method returns the number of characters copied, not including the terminating null character.

The second overloaded method returns the retrieved text.

Usage examples

Retrieve all the text using the first overloaded method:

DIM cbLen AS LONG = pRichEdit.GetTextLEngth
DIM wstrText AS DWSTRING = WSPACE(cbLen + 1)
DIM trg AS TEXTRANGEW
trg.chrg.cpMin = 0
trg.chrg.cpMax = -1
trg.lpstrText = wstrtext
pRichEdit.GetTextRange(trg)
AfxMsg wstrtext

Retrieve all the text using the second overloaded method:

DIM dws AS DWSTRING = pRichEdit.GetTextRange
AfxMsg dws

Retrieve a range of text.

DIM sws AS DWSTRING = pRichEdit.GetTextRange(5, 15)
AfxMsg sws

GetThumb

Gets the position of the scroll box (thumb) in the vertical scroll bar of a multiline rich edit control.

FUNCTION GetThumb () AS LONG
Return value

The return value is the position of the scroll box.

UndoName

Retrieves the type of the next undo action, if any.

FUNCTION UndoName () AS DWORD
FUNCTION GetUndoName () AS DWORD
Return value

If there is an undo action, the value returned is an UNDONAMEID enumeration value that indicates the type of the next action in the control's undo queue.

If there are no actions that can be undone or the type of the next undo action is unknown, the return value is zero.

UNDONAMEID enumeration

4

NameValueDescription
UID_UNKNOWN0The type of undo action is unknown.
UID_TYPING1Typing operation.
UID_DELETE2Delete operation.
UID_DRAGDROP3Drag-and-drop operation.
UID_CUT4Cut operation.
UID_PASTE5Paste operation.
UID_AUTOTABLE6Automatic table insertion; for example, typing +---+---+<Enter> to insert a table row.
Remarks

The types of actions that can be undone or redone include typing, delete, drag, drop, cut, and paste operations. This information can be useful for applications that provide an extended user interface for undo and redo operations, such as a drop-down list box of actions that can be undone.


GetZoom

Gets the current zoom ratio, which is always between 1/64 and 64.

FUNCTION GetZoom (BYREF pzNum AS DWORD, BYREF pzDen AS DWORD) AS LONG
ParameterDescription
zNum*A DWORD variable that receives the numerator of the zoom ratio.
zDen*A DWORD variable that receives the denominator of the zoom ratio..
Return value

The message returns TRUE if message is processed, which it will be if both pzNum and pzDen are not NULL.


HideSelection

Hides or shows the selection in a rich edit control.

SUB HideSelection (BYVAL fHide AS DWORD)
ParameterDescription
fHideValue specifying whether to hide or show the selection. If this parameter is zero, the selection is shown. Otherwise, the selection is hidden.
Return value

This message does not return a value.


InsertImage

Overloaded method that replaces the selection with a blob that displays an image. It uses pixels instead of HIMETRIC units and it is DPI aware. Can insert and display .bmp, .jpg, .png and .gif files.

FUNCTION InsertImage OVERLOAD (BYREF wszFileName AS WSTRING, BYVAL xWidth AS LONG = 0, BYVAL yHeight AS LONG = 0, _
BYVAL Ascent AS LONG = 0, BYVAL nType AS LONG = TA_BASELINE, BYREF wszAlternateText AS WSTRING = "") AS BOOLEAN
ParameterDescription
wszFileNamePath and name of the image file to load.
xWidthOptional. Image width in pixels. If both xWidth and yWidth parameters are 0, the method retrieves the size of the image using GDI+.
yHeightOptional. Image heigh in pixels. If both xWidth and yWidth parameters are 0, the method retrieves the size of the image using GDI+.
AscentOptional. If nType is TA_BASELINE (the default value), this parameter is the distance, in pixels, that the top of the image extends above the text baseline. If nType is TA_BASELINE and ascent is zero, the bottom of the image is placed at the text baseline.
nTypeOptional. The vertical alignment of the image. It can be one of the following values.
TA_BASELINE. Align the image relative to the text baseline.
TA_BOTTOM. Align the bottom of the image at the bottom of the text line.
TA_TOP. Align the top of the image at the top of the text line.
wszAlternateTextOptional. The alternate text for the image.
Return value

Returns a boolean value: 0 for success and -1 for failure. To get extended error information call GetErrorInfo, which can return S_OK if successful, or one of the following error codes.

Return codeDescription
E_FAILCannot insert the image.
E_INVALIDARGInvaid argument
E_OUTOFMEMORYInsufficient memory is available.

Overloaded method that replaces the selection with a blob that displays an image. Uses HIMETRIC units.

FUNCTION InsertImage OVERLOAD (BYREF ip AS RICHEDIT_IMAGE_PARAMETERS) AS DWORD
ParameterDescription
ipA RICHEDIT_IMAGE_PARAMETERS structure that contains the image blob.
Return value

Returns S_OK if successful, or one of the following error codes.

Return codeDescription
E_FAILCannot insert the image.
E_INVALIDARGThe ip parameter is NULL or points to an invalid image.
E_OUTOFMEMORYInsufficient memory is available.

InsertObject

Inserts an image or a Ole object in the rich edit control. See MSDN: https://learn.microsoft.com/en-us/windows/win32/controls/using-rich-edit-com Remarks: To insert images, use the InsertImage method, because the InsertObject method won't display the image, but an icon, when the image type is not a bitmap.

FUNCTION InsertObject (BYREF wszFileName AS WSTRING) AS BOOLEAN
ParameterDescription
wszFileNameThe path and file name of the image file.
Return value

Returns a boolean true (-1) for success of false (0) for failure. To get extended information call the GetErrorInfo method.


InsertTable

Inserts one or more identical table rows with empty cells.

FUNCTION InsertTable (BYREF tp AS TABLEROWPARMS, BYREF tcp AS TABLECELLPARMS) AS DWORD
ParameterDescription
tpA TABLEROWPARMS structure.
tcpA TABLECELLPARMS structure.
Return value

Returns S_OK if the table is inserted, or an error code if not.

Remarks

If the cpStartRow member of the TABLEROWPARMS is –1, this message deletes the selected text (if any), and then inserts empty table rows with the row and cell parameters given by lptp^ and lptcp. It leaves the selection pointing to the start of the first cell in the first row. The client can then populate the table cells by pointing the selection (or an ITextRange) to the various cell end marks and inserting and formatting the desired text. Such text can include nested table rows. Alternatively, if the cpStartRow member of the TABLEROWPARMS is 0 or greater, table rows are inserted at the character position given by cpStartRow. This only changes the current selection if the table is inserted inside the selected text.

A Microsoft Rich Edit table consists of a sequence of table rows which, in turn, consist of sequences of paragraphs. A table row starts with the special two-character delimiter paragraph U+FFF9 U+000D and ends with the two-character delimiter paragraph U+FFFB U+000D. Each cell is terminated by the cell mark U+0007, which is treated as a hard end-of-paragraph mark just as U+000D (CR) is. The table row and cell parameters are treated as special paragraph formatting of the table-row delimiters. The formatting contains the information in the TABLEROWPARMS structure. The cell parameters given by the TABLECELLPARMS structure are stored in an expanded version of the tabs array. This format allows tables to be nested within other tables, up to fifteen levels deep.


IsIME

Determines if current input locale is an East Asian locale.

FUNCTION IsIME () AS LONG
Return value

Returns TRUE if it is an East Asian locale. Otherwise, it returns FALSE.


LineFromChar

Gets the index of the line that contains the specified character index in a multiline rich edit control.

FUNCTION LineFromChar (BYVAL index AS DWORD) AS LONG
ParameterDescription
indexThe character index of the character contained in the line whose number is to be retrieved. If this parameter is -1, LineFromChar retrieves either the line number of the current line (the line containing the caret) or, if there is a selection, the line number of the line containing the beginning of the selection.
Return value

The return value is the zero-based line number of the line containing the character index specified by index.


LineIndex

Gets the character index of the first character of a specified line in a multiline rich edit control.

FUNCTION LineIndex (BYVAL nLine AS LONG) AS LONG
ParameterDescription
nLineThe zero-based line number. A value of -1 specifies the current line number (the line that contains the caret).
Return value

The return value is the character index of the line specified in the nLine parameter, or it is -1 if the specified line number is greater than the number of lines in the edit control.


LineLength

Retrieves the length, in characters, of a line in a rich edit control.

FUNCTION LineLength (BYVAL index AS DWORD) AS LONG
ParameterDescription
indexThe character index of a character in the line whose length is to be retrieved. If this parameter is greater than the number of characters in the control, the return value is zero.
This parameter can be -1. In this case, the message returns the number of unselected characters on lines containing selected characters. For example, if the selection extended from the fourth character of one line through the eighth character from the end of the next line, the return value would be 10 (three characters on the first line and seven on the next).
Return value

If index is greater than the number of characters in the control, the return value is zero.


LineScroll

Scrolls the text in a multiline rich edit control.

FUNCTION LineScroll (BYVAL y AS LONG) AS LONG
ParameterDescription
yThe number of lines to scroll vertically.
Return value

TRUE or FALSE.

Remarks

The control does not scroll vertically past the last line of text in the edit control. If the current line plus the number of lines specified by the y parameter exceeds the total number of lines in the edit control, the value is adjusted so that the last line of the edit control is scrolled to the top of the edit-control window.


Margins

Sets the widths of the left and right margins for a rich edit control. The message redraws the control to reflect the new margins.

FUNCTION Margins (BYVAL nMargins AS LONG, BYVAL nWidth AS LONG)
SUB SetMargins (BYVAL nMargins AS LONG, BYVAL nWidth AS LONG)
PROPERTY LeftMargin (BYVAL nWidth AS LONG)
PROPERTY RightMargin (BYVAL nWidth AS LONG)
SUB SetLeftMargin (BYVAL nWidth AS LONG)
SUB SetRightMargin (BYVAL nWidth AS LONG)
ParameterDescription
nMarginsThe margins to set. This parameter can be one or more of the following values.
EC_LEFTMARGIN. Sets the left margin.
EC_RIGHTMARGIN. Sets the right margin.
EC_USEFONTINFO. Sets the left and right margins to a narrow width calculated using the text metrics of the control's current font. If no font has been set for the control, the margins are set to zero. The nWidth parameter is ignored.
nWidthThe LOWORD specifies the new width of the left margin, in pixels. This value is ignored if nMargins does not include EC_LEFTMARGIN.
Rich Edit 3.0 and later: The LOWORD can specify the EC_USEFONTINFO value to set the left margin to a narrow width calculated using the text metrics of the control's current font. If no font has been set for the control, the margin is set to zero.
The HIWORD specifies the new width of the right margin, in pixels. This value is ignored if nMargins does not include EC_RIGHTMARGIN.
Rich Edit 3.0 and later: The HIWORD can specify the EC_USEFONTINFO value to set the right margin to a narrow width calculated using the text metrics of the control's current font. If no font has been set for the control, the margin is set to zero
Usage examples

Set the left margin

pRichEdit.SetMargins(EC_LEFTMARGIN, MAKELONG(50, 0))
--or--
pRichEdit.SetMargins(EC_LEFTMARGIN, MAKELONG(50))
--or--
pRichEdit.Margins(EC_LEFTMARGIN) = MAKELONG(50, 0)
--or--
pRichEdit.LeftMargin = 50

Set the right margin

pRichEdit.SetMargins(EC_RIGHTMARGIN, MAKELONG(0, 50))
--or--
pRichEdit.Margins(EC_RIGHTMARGIN) = MAKELONG(0, 50)
--or--
pRichEdit.RightMargin = 50

Set both margins

pRichEdit.SetMargins(EC_LEFTMARGIN OR EC_RIGHTMARGIN, MAKELONG(50, 50))
--or--
pRichEdit.Margins(EC_LEFTMARGIN OR EC_RIGHTMARGIN) = MAKELONG(50, 50)

PasteSpecial

Pastes a specific clipboard format in a rich edit control.

SUB PasteSpecial OVERLOAD (BYVAL clpfmt AS DWORD, BYREF rps AS REPASTESPECIAL)
SUB PasteSpecial OVERLOAD (BYVAL clpfmt AS DWORD, BYVAL dwAspect AS DWORD, BYVAL hMF AS HMETAFILE)
ParameterDescription
clpfmtSpecifies the Clipboard Formats.
rpsA REPASTESPECIAL structure or NULL. If an object is being pasted, the REPASTESPECIAL structure is filled in with the desired display aspect. If clpfmt is NULL or the dwAspect member is zero, the display aspect used will be the contents of the object descriptor.
dwAspectDisplay aspect. It can be one of the following values.
DVASPECT_CONTENT. Aspect is based on the content of the object.
DVASPECT_ICON. Aspect is based on the icon view of the object.
hMFAspect data. If dwAspect is DVASPECT_ICON, this member contains the handle to the metafile with the icon view of the object.

PosFromChar

Retrieves the client area coordinates of a specified character in a rich edit control.

FUNCTION PosFromChar (BYVAL index as DWORD) AS .POINTL
ParameterDescription
indexThe zero-based index of the character.
Return value

A POINTL structure with receives the client area coordinates of the character. The coordinates are in screen units and are relative to the upper-left corner of the control's client area.

Remarks

A returned coordinate can be a negative value if the specified character is not displayed in the edit control's client area. The coordinates are truncated to integer values.

If the character is a line delimiter, the returned coordinates indicate a point just beyond the last visible character in the line. If the specified index is greater than the index of the last character in the control, the control returns -1.


Reconversion

Invokes the Input Method Editor (IME) reconversion dialog box.

SUB Reconversion ()
Return value

Thismethod does not return a value.


Redo

Redoes the next action in the control's redo queue.

FUNCTION Redo () AS LONG
Return value

If the Redo operation succeeds, the return value is a nonzero value. If the Redo operation fails, the return value is zero.

Remarks

To determine whether there are any actions in the control's redo queue, call the CanRedo method.


ReplaceSel

Replaces the current selection in a rich edit control with the specified text.

SUB ReplaceSel (BYVAL bCanBeUndone AS LONG = TRUE, BYREF wszText AS WSTRING)
ParameterDescription
bCanBeUndoneSpecifies whether the replacement operation can be undone. If this is TRUE, the operation can be undone. If this is FALSE, the operation cannot be undone.
wszTextA WSTRING containing the replacement text.
Remarks

Use the ReplaceSel method to replace only a portion of the text in an edit control. To replace all of the text, use the Text property.

If there is no selection, the replacement text is inserted at the caret.

In a rich edit control, the replacement text takes the formatting of the character at the caret or, if there is a selection, of the first character in the selection.


RequestResize

Forces a rich edit control to send an EN_REQUESTRESIZE notification message to its parent window.

SUB RequestResize ()
Remarks

This message is useful during WM_SIZE processing for the parent of a bottomless rich edit control.


Scroll

Scrolls the text vertically in a multiline rich edit control.

FUNCTION Scroll (BYVAL nAction AS LONG) AS LONG
ParameterDescription
nActionThe action the scroll bar is to take. This parameter can be one of the following values:
SB_LINEDOWN. Scrolls down one line.
SB_LINEUP. Scrolls up one line.
SB_PAGEDOWN. Scrolls down one page.
SB_PAGEUP. Scrolls up one page.
Return value

If the method is successful, the HIWORD of the return value is TRUE, and the LOWORD is the number of lines that the command scrolls. The number returned may not be the same as the actual number of lines scrolled if the scrolling moves to the beginning or the end of the text. If the nAction parameter specifies an invalid value, the return value is FALSE.

Remarks

To scroll to a specific line or character position, use the LineScroll method. To scroll the caret into view, use the ScrollCaret method.


ScrollCaret

Scrolls the caret into view in a rich edit control.

SUB ScrollCaret ()
Return value

The return value is not meaningful.


SelectionType

Determines the selection type for a rich edit control.

FUNCTION SelectionType () AS LONG
Return value

If the selection is not empty, the return value is a set of flags containing one or more of the following values.

Return codeDescription
SEL_TEXTText.
SEL_OBJECTAt least one COM object.
SEL_MULTICHARMore than one character of text.
SEL_MULTIOBJECTMore than one COM object.
Remarks

This message is useful during WM_SIZE processing for the parent of a bottomless rich edit control.


SetBkgndColor

Sets the background color for a rich edit control.

FUNCTION SetBkgndColor (BYVAL SysColor AS DWORD, BYVAL BkColor AS DWORD) AS DWORD
ParameterDescription
SysColorSpecifies whether to use the system color. If this parameter is a nonzero value, the background is set to the window background system color. Otherwise, the background is set to the specified color.
BkColorA COLORREF structure specifying the color if SysColor is zero. To generate a COLORREF, use the RGB macro (renamed as BGR in the FreeBasic Windows headers).
Return value

This message returns the original background color.


SetFontSize

Sets the font size for the selected text.

FUNCTION SetFontSize (BYVAL ptsize AS LONG) AS LONG
ParameterDescription
ptsizeChange in point size of the selected text. The result will be rounded according to values shown in the following table. This parameter should be in the range of -1637 to 1638. The resulting font size will be within the range of 1 to 1638.
Return value

If no error occurred, the return value is TRUE. If an error occurred, the return value is FALSE.

Remarks

You can easily get the font size by calling the CharFormat property.

Rich Edit first adds ptsize to the current font size and then uses the resulting size and the following table to determine the rounding value.

BandRounding value
<=121
282
360
480
720
800
8010

If the resulting font size is not evenly divisible by the rounding value, the font size is then rounded to a number evenly divisible by the rounding value. So if the font size is less than or equal to 12, the rounding value will be 1. Similarly, if the font size is less than or equal to 28, the rounding value is 2. For values greater than 28, font sizes are rounded to the next band. So, the font size jumps to 36, 48, 72, 80. After 80, all rounding is done in increments of ten points.

The font size is rounded up or down depending on the sign of ptsize. If ptsize is positive, the rounding is always up. Otherwise, rounding is always down. So, if the current font size is 10 and ptsize is 3, the resulting font size would be 14 (10 + 3 = 13, which is not divisible by 2, so the size rounds up to 14). Conversely, if the current font size is 14 and ptsize is -3, the resulting font size would be 10 (14 - 3 = 11, which is not divisible by 2, so the size rounds down to 10).

The change is applied to each part of the selection. So, if some of the text is 10pt and some 20pt, after a call with ptsize set to 1, the font sizes become 11pt and 22pt, respectively.

Additional examples are shown in the following table.

Original font sizeptsizeResulting font size
718
7310
10314
14-310
28136
28336
80190
80-172

SetIMEColor

Sets the Input Method Editor (IME) composition color. This message is available only in Asian-language versions of the operating system.

FUNCTION SetIMEColor (BYVAL pcompcolor AS .COMPCOLOR PTR) AS LONG
   RETURN this.SetResult(SendMessageW(m_hRichEdit, EM_SETIMECOLOR, 0, cast(LPARAM, pcompcolor)))
END FUNCTION
ParameterDescription
pcompcolorPointer to a COMPCOLOR structure that contains the composition color to be set..
Return value

If the operation succeeds, the return value is a nonzero value. If the operation fails, the return value is zero. Call GetErrorInfo to get information about the result.

Note

This message is supported only in Asian-language versions of Microsoft Rich Edit 1.0. It is not supported in any later versions.


SetOleCallback

Gives a rich edit control an IRichEditOleCallback object that the control uses to get OLE-related resources and information from the client.

FUNCTION SetOleCallback (BYVAL pCallback AS ANY PTR) AS LONG
ParameterDescription
pCallbackPointer to an IRichEditOleCallback object. The control calls the AddRef method for the object before returning.
Return value

If the operation succeeds, the return value is a nonzero value. If the operation fails, the return value is zero.


SetPalette

Changes the palette that a rich edit control uses for its display window.

SUB SetPalette (BYVAL newPalette AS HPALETTE)
ParameterDescription
newPaletteHandle to the new palette used by the rich edit control.
Return value

This method does notreturn a value.

Remarks

The rich edit control does not check whether the new palette is valid.


SetReadOnly

Sets or removes the read-only style (ES_READONLY) of a rich edit control.

FUNCTION SetReadOnly (BYVAL fReadOnly AS LONG) AS BOOLEAN
ParameterDescription
fReadOnlySpecifies whether to set or remove the ES_READONLY style. A value of TRUE sets the ES_READONLY+* style; a value of **FALSE removes the ES_READONLY style.
Return value

Returns the boolean true (-1) or false (0).

Remarks

When an edit control has the ES_READONLY style, the user cannot change the text within the edit control.

To determine whether an edit control has the ES_READONLY style, use the Windows API GetWindowLong function with the GWL_STYLE flag.


SetSel

Selects a range of characters in a rich edit control.

SUB SetSel OVERLOAD (BYVAL nStart AS LONG, BYVAL nEnd AS LONG)
SUB SetSel OVERLOAD (BYREF pt AS POINTL)
ParameterDescription
nStartThe starting character position of the selection.
nEndThe ending character position of the selection.
ParameterDescription
ptA POINTL structure with its x and y members set to the starting and ending characters positions of the selection.
Remarks

The start value can be greater than the end value. The lower of the two values specifies the character position of the first character in the selection. The higher value specifies the position of the first character beyond the selection.

The start value is the anchor point of the selection, and the end value is the active end. If the user uses the SHIFT key to adjust the size of the selection, the active end can move but the anchor point remains the same.

If the start is 0 and the end is -1, all the text in the edit control is selected. If the start is -1, any current selection is deselected.

If the edit control has the ES_NOHIDESEL style, the selected text is highlighted regardless of whether the control has focus. Without the ES_NOHIDESEL style, the selected text is highlighted only when the edit control has the focus.


SetTableParams

Changes the parameters of rows in a table.

FUNCTION SetTableParams (BYREF tp AS TABLEROWPARMS, BYREF tcp AS TABLECELLPARMS) AS DWORD
ParameterDescription
hRichEditThe handle of the rich edit control.
lptpA pointer to a TABLEROWPARMS structure.
lptcpA pointer to a TABLECELLPARMS structure.
Return value

Returns S_OK if successful, or one of the following error codes.

Return codeDescription
E_FAILChanges cannot be made. This can occur if the control is a plain-text or single-line control, or if the insertion point is inside a math object. It also occurs if tables are disabled if the EditStyleEx property sets the SES_EX_NOTABLE value.
E_INVALIDARGThe lptp or lptcp parameters are NULL or point to an invalid structure. The cbRow member of the TABLEROWPARMS structure must equal sizeof(TABLEROWPARMS) or sizeof(TABLEROWPARMS) 2*sizeof(long). The latter value is the size of the RichEdit 4.1 TABLEROWPARMS structure. The cbCell member of the TABLEROWPARMS structure must equal sizeof(TABLECELLPARMS). The query character position must be at a table row delimiter.
E_OUTOFMEMORYInsufficient memory is available.
Remarks

This message changes the parameters of the number of rows specified by the cRow member of the TABLEROWPARMS structure, if the table has that many consecutive rows. If cRow is less than 0, the message iterates until the end of the table. If the new cell count differs from the current cell count by +1 or 1, it inserts or deletes the cell at the index specified by the iCell member of TABLEROWPARMS. The starting table row is identified by a character position. This position is specified by cpStartRow members with values that are greater than or equal to zero. The position should be inside the table row, but not inside a nested table, unless you want to change that table s parameters. If the cpStartRow member is 1, the character position is given by the current selection. For this, position the selection anywhere inside the table row, or select the row with the active end of the selection at the end of the table row.


SetTabStops

Sets the tab stops in a multiline rich edit control.

FUNCTION SetTabStops (BYVAL nTabs AS LONG, BYVAL rgTabStops AS LONG_PTR) AS LONG
ParameterDescription
nTabsThe number of tab stops contained in the array. If this parameter is zero, the rgTabStops parameter is ignored and default tab stops are set at every 32 dialog template units. If this parameter is 1, tab stops are set at every n dialog template units, where n is the distance pointed to by the rgTabStops parameter. If this parameter is greater than 1, rgTabStops is a pointer to an array of tab stops.
rgTabStopsA pointer to an array of unsigned integers specifying the tab stops, in dialog template units. If the nTabs parameter is 1, this parameter is a pointer to an unsigned integer containing the distance between all tab stops, in dialog template units.
Return value

If all the tabs are set, the return value is TRUE.

If all the tabs are not set, the return value is FALSE.

Remarks

The EM_SETTABSTOPS message does not automatically redraw the edit control window. If the application is changing the tab stops for text already in the edit control, it should call the Windows API InvalidateRect function to redraw the edit control window.

The values specified in the array are in dialog template units, which are the device-independent units used in dialog box templates. To convert measurements from dialog template units to screen units (pixels), use the Windows API MapDialogRect function.

Rich Edit: Supported in Microsoft Rich Edit 3.0 and later. A rich edit control can have the maximum number of tab stops specified by MAX_TAB_STOPS.


SetTargetDevice

Sets the target device and line width used for WYSIWYG formatting in a rich edit control.

FUNCTION SetTargetDevice (BYVAL hDC AS HDC, BYVAL lnwidth AS LONG) AS BOOLEAN
ParameterDescription
hDCHDC [Handle to a Device Context] for the target device.
lnwidthLine width to use for formatting.
Return value

If the method succeeds it returns the boolean value true (-1); if it fails, it returns false (0).

Remarks

The HDC for the default printer can be obtained as follows.

DIM hdc AS HDC
DIM pd AS PRINTDLGW
pd.lStructSize = SIZEOF(pd)
pd.flags = PD_RETURNDC OR PD_RETURNDEFAULT
IF PrintDlgW(@pd) THEN
   hdc =  = pd.hDC
END IF

If lnwidth is zero, no line breaks are created.


SetTextEx / InsertText / ReplaceText

Combines the functionality of WM_SETTEXT and EM_REPLACESEL and adds the ability to set text using a code page and to use either Rich Text Format (RTF) rich text or plain text.

FUNCTION SetTextEx OVERLOAD (BYREF stex AS SETTEXTEX, BYVAL buffer AS ANY PTR) AS DWORD
FUNCTION SetTextEx OVERLOAD (BYREF stex AS .SETTEXTEX, BYREF strText AS STRING) AS DWORD
FUNCTION SetTextEx OVERLOAD (BYREF stex AS .SETTEXTEX, BYREF wszText AS WSTRING) AS DWORD
FUNCTION SetTextEx OVERLOAD (BYREF strText AS STRING) AS DWORD
FUNCTION SetTextEx OVERLOAD (BYREF wszText AS WSTRING) AS DWORD
FUNCTION SetTextEx OVERLOAD (BYVAL nStart AS LONG, BYVAL nEnd AS LONG, BYREF strText AS STRING) AS DWORD
FUNCTION SetTextEx OVERLOAD (BYVAL nStart AS LONG, BYVAL nEnd AS LONG, BYREF wszText AS WSTRING) AS DWORD
FUNCTION SetTextEx OVERLOAD (BYVAL nPos AS LONG, BYREF strText AS STRING) AS DWORD
FUNCTION SetTextEx OVERLOAD (BYVAL nPos AS LONG, BYREF wszText AS WSTRING) AS DWORD
FUNCTION InsertText OVERLOAD (BYREF strText AS STRING) AS DWORD
FUNCTION InsertText OVERLOAD (BYREF wszText AS WSTRING) AS DWORD
FUNCTION InsertText OVERLOAD (BYVAL nPos AS LONG, BYREF strText AS STRING) AS DWORD
FUNCTION InsertText OVERLOAD (BYVAL nPos AS LONG, BYREF wszText AS WSTRING) AS DWORD
FUNCTION ReplaceText OVERLOAD (BYVAL nStart AS LONG, BYVAL nEnd AS LONG, BYREF strText AS STRING) AS DWORD
FUNCTION ReplaceText OVERLOAD (BYVAL nStart AS LONG, BYVAL nEnd AS LONG, BYREF wszText AS WSTRING) AS DWORD
ParameterDescription
stexA SETTEXTEX structure that specifies flags and an optional code page to use in translating to Unicode.
bufferPointer to the null-terminated text to insert. This text is an ANSI string, unless the code page is 1200 (Unicode). If pwszText starts with a valid RTF ASCII sequence for example, "{\rtf" or "{urtf" the text is read in using the RTF reader.
ParameterDescription
nStartStart position.
nEndEnd position.
nPosPosition.
strTextAnsi text.
wszTextUnicode text.

SETTEXTEX flags

Option flags. It can be any reasonable combination of the following flags.

FlagValueDescription
ST_DEFAULT&h00Deletes the undo stack, discards rich-text formatting, replaces all text.
ST_KEEPUNDO&h01Keeps the undo stack.
ST_SELECTION&h02Replaces selection and keeps rich-text formatting.
ST_NEWCHARS&h04Act as if new characters are being entered.
ST_UNICODE&h08The text is UTF-16 (the WCHAR data type).
ST_PLACEHOLDERTEXT&h10Placeholder text that is visible only when focus is not on the RichEdit control and the control does not contain any user-specified text.
ST_PLAINTEXTONLY&h20RichEdit control supports plain text only.

SETTEXTEX codepage

The code page used to translate the text to Unicode. If codepage is 1200 (Unicode code page), no translation is done. If codepage is CP_ACP, the system code page is used.

Return value

If the operation is setting all of the text and succeeds, the return value is 1.

If the operation is setting the selection and succeeds, the return value is the number of bytes or characters copied.

If the operation fails, the return value is zero.

Usage examples

Inserts ansi text at the caret position:

DIM stex AS .SETTEXTEX
stex.flags = ST_SELECTION OR ST_KEEPUNDO
stex.codepage = CP_ACP
DIM st AS STRING = "New text"
pRichEdit->SetTextEx(stex, st)
--or--
pRichEdit->SetTextEx(st)
--or--
pRichEdit->InsertTextEx(st)

Inserts formatted rich text at the caret position:

DIM stex AS .SETTEXTEX
stex.flags = ST_SELECTION OR ST_KEEPUNDO
stex.codepage = CP_ACP
DIM st AS STRING = $"{\rtf1\ansi New text}"
pRichEdit->SetTextEx(stex, st)
--or--
pRichEdit->SetTextEx(st)
--or--
pRichEdit->InsertTextEx(st)

Inserts unicode text at the caret position:

DIM stex AS .SETTEXTEX
stex.flags = ST_SELECTION OR ST_KEEPUNDO
stex.codepage = 1200
DIM wsz AS WSTRING * 10 = "New text"
pRichEdit->SetTextEx(stex, wsz)
--or--
pRichEdit->SetTextEx(wsz)
--or--
pRichEdit->InsertTextEx(wsz)
DIM stex AS .SETTEXTEX
stex.flags = ST_SELECTION OR ST_KEEPUNDO
stex.codepage = 1200
DIM sws AS DWSTRING = "New text"
pRichEdit->SetTextEx(stex, dws)
--or--
pRichEdit->SetTextEx(dws)
--or--
pRichEdit->InsertTextEx(dws)

Replaces text

pRichEdit->SetTextEx (10, 20, "New Text")
DIM st AS STRING = "New text"
pRichEdit->SetTextEx (10, 20, st)
DIM st AS STRING = $"{\rtf1\ansi New text}"
pRichEdit->SetTextEx (10, 20, st)
DIM wsz AS WSTRING * 10 = "New text"
pRichEdit->SetTextEx (10, 20, wsz)
DIM dws AS DWSTRING = "New text"
pRichEdit->SetTextEx (10, 20, dws)

Inserts text at the specified position:

pRichEdit->SetTextEx (10, "New Text")
DIM st AS STRING = "New text"
pRichEdit->SetTextEx (10, st)
DIM st AS STRING = $"{\rtf1\ansi New text}"
pRichEdit->SetTextEx (10, st)
DIM wsz AS WSTRING * 10 = "New text"
pRichEdit->SetTextEx (10, wsz)
DIM dws AS DWSTRING = "New text"
pRichEdit->SetTextEx (10, dws)

Delete text:

pRichEdit->SetTextEx (10, 20, "")

SetUIAName

Sets the name of a rich edit control for UI Automation (UIA).

FUNCTION SetUIAName (BYREF wszName AS WSTRING) AS DWORD
ParameterDescription
wszNameA WSTRING with the name.
Return value

TRUE if the name for UIA is successfully set, otherwise FALSE.


SetUndoLimit

Sets the maximum number of actions that can stored in the undo queue.

FUNCTION SetUndoLimit (BYVAL maxactions AS DWORD) AS DWORD
ParameterDescription
maxactionsSpecifies the maximum number of actions that can be stored in the undo queue.
Return value

The return value is the new maximum number of undo actions for the rich edit control. This value may be less than maxactions if memory is limited.

Remarks

By default, the maximum number of actions in the undo queue is 100. If you increase this number, there must be enough available memory to accommodate the new number. For better performance, set the limit to the smallest possible value.

Setting the limit to zero disables the Undo feature.


SetZoom

Sets the zoom ratio for a multiline edit control or a rich edit control. The ratio must be a value between 1/64 and 64. The edit control needs to have the ES_EX_ZOOMABLE extended style set, for this message to have an effect, see Edit Control Extended Styles.

FUNCTION SetZoom (BYVAL zNum AS DWORD, BYVAL zDen AS DWORD) AS LONG
ParameterDescription
zNumNumerator of the zoom ratio.
zDenDenominator of the zoom ratio. These parameters can have the following values.
ValueMeaning
Both 0Turns off zooming by using the EM_SETZOOM message (zooming may still occur using TxGetExtent.
1/64 < (wParam / lParam) < 64Zooms display by the zoom ratio numerator/denominator
Return value

If the new zoom setting is accepted, the return value is TRUE. If the new zoom setting is not accepted, the return value is FALSE.


ShowScrollBar

Shows or hides one of the scroll bars in the Text Host window.

SUB ShowScrollBar (BYVAL nScrollBar AS DWORD, BYVAL fShow AS LONG)
ParameterDescription
nScrollBarIdentifies which scroll bar to display: horizontal or vertical. This parameter must be SB_VERT or SB_HORZ.
fShowSpecifies whether to show the scroll bar or hide it. Specify TRUE to show the scroll bar and FALSE to hide it.
Remarks

This method is only valid when the control is in-place active. Calls made while the control is inactive may fail.


StopGroupTyping

Stops the control from collecting additional typing actions into the current undo action.

FUNCTION StopGroupTyping () AS DWORD
Return value

The return value is zero. This message cannot fail.

Remarks

A rich edit control groups consecutive typing actions, including characters deleted by using the BackSpace key, into a single undo action until one of the following events occurs:

  • The control receives an EM_STOPGROUPTYPING message.
  • The control loses focus.
  • The user moves the current selection, either by using the arrow keys or by clicking the mouse.
  • The user presses the Delete key.
  • The user performs any other action, such as a paste operation that does not involve typing.

You can send the RichEdit_StopGroupTyping message to break consecutive typing actions into smaller undo groups. For example, you could send RichEdit_StopGroupTyping after each character or at each word break.


StreamIn

Replaces the contents of a rich edit control with a stream of data provided by an application defined EditStreamCallback callback function.

FUNCTION StreamIn (BYVAL psf AS LONG, BYREF edst AS EDITSTREAM) AS DWORD
ParameterDescription
psfSpecifies the data format and replacement options. This value must be one of the following values (see table below).
pedstA EDITSTREAM structure. On input, the pfnCallback member of this structure must point to an application defined EditStreamCallback function. On output, the dwError member can contain a nonzero error code if an error occurred.
Data format and replacement options
ValueMeaning
SF_RTFRTF
SF_TEXTText

In addition, you can specify the following flags.

ValueMeaning
SFF_PLAINRTFIf specified, only keywords common to all languages are streamed in. Language-specific RTF keywords in the stream are ignored. If not specified, all keywords are streamed in. You can combine this flag with the SF_RTF flag.
SFF_SELECTIONIf specified, the data stream replaces the contents of the current selection. If not specified, the data stream replaces the entire contents of the control. You can combine this flag with the SF_TEXT or SF_RTF flags.
SF_UNICODERich Edit 2.0 and later: Indicates Unicode text. You can combine this flag with the SF_TEXT flag.
SF_USECODEPAGERich Edit 3.0 and later: Reads UTF-8 RTF and text using other code pages. The code page is set in the high word of psf. For example, for UTF-8 RTF, set psf to (CP_UTF8 << 16)SF_USECODEPAGESF_RTF.
Return value

This message returns the number of characters read.

Remarks

When you call the StreamIn methos, the rich edit control makes repeated calls to the EditStreamCallback function specified by the pfnCallback member of the EDITSTREAM structure. Each time the callback function is called, it fills a buffer with data to read into the control. This continues until the callback function indicates that the stream-in operation has been completed or an error occurs.


StreamOut

Causes a rich edit control to pass its contents to an application defined EditStreamCallback callback function. The callback function can then write the stream of data to a file or any other location that it chooses.

FUNCTION StreamOut (BYVAL psf AS LONG, BYREF edst AS EDITSTREAM) AS DWORD
ParameterDescription
psfSpecifies the data format and replacement options. This value must be one of the following values (see table below).
pedstA EDITSTREAM structure. On input, the pfnCallback member of this structure must point to an application defined EditStreamCallback function. On output, the dwError member can contain a nonzero error code if an error occurred.
Data format and replacement options
ValueMeaning
SF_RTFRTF
SF_RTFNOOBJSRTF with spaces in place of COM objects.
SF_TEXTText
SF_TEXTIZEDText with a text representation of COM objects.

The SF_RTFNOOBJS option is useful if an application stores COM objects itself, as RTF representation of COM objects is not very compact. The control word, \objattph, followed by a space denotes the object position.

In addition, you can specify the following flags.

ValueMeaning
SFF_PLAINRTFIf specified, the rich edit control streams out only the keywords common to all languages, ignoring language-specific keywords. If not specified, the rich edit control streams out all keywords. You can combine this flag with the SF_RTF or SF_RTFNOOBJS flag.
SFF_SELECTIONIf specified, the rich edit control streams out only the contents of the current selection. If not specified, the control streams out the entire contents. You can combine this flag with any of data format values.
SF_UNICODERich Edit 2.0 and later: Indicates Unicode text. You can combine this flag with the SF_TEXT flag.
SF_USECODEPAGERich Edit 3.0 and later: Reads UTF-8 RTF and text using other code pages. The code page is set in the high word of psf. For example, for UTF-8 RTF, set psf to (CP_UTF8 << 16)SF_USECODEPAGESF_RTF.
Return value

This message returns the number of characters written to the data stream.

Remarks

When you call the StreamOut method, the rich edit control makes repeated calls to the EditStreamCallback function specified by the pfnCallback member of the EDITSTREAM structure. Each time it calls the callback function, the control passes a buffer containing a portion of the contents of the control. This process continues until the control has passed all its contents to the callback function, or until an error occurs.


Undo

First overloaded function: Undoes the last edit control operation in the control's undo queue.

Second overloaded function: Performs a specified number of undo operations.

SuspendUndo: Suspends undo processing.

ResumeUndo: Resumes undo processing.

FUNCTION Undo () AS LONG
FUNCTION Undo (BYVAL Count AS LONG) AS LONG
DECLARE FUNCTION SuspendUndo () AS LONG
DECLARE FUNCTION ResumeUndo () AS LONG
ParameterDescription
CountThe specified number of undo operations. If the value of this parameter is tomFalse, undo processing is suspended. If this parameter is tomTrue, undo processing is restored.
Return value

First overloaded function: For a single-line edit control, the return value is always TRUE. For a multiline edit control, the return value is TRUE if the undo operation is successful, or FALSE if the undo operation fails.

Second overloaded function: The actual count of undo operations performed. If all of the Count undo operations were performed, it returns S_OK. If the method fails, it returns S_FALSE, indicating that less than Count undo operations were performed.

Remarks

Edit controls and Rich Edit 1.0: An undo operation can also be undone. For example, you can restore deleted text with the first EM_UNDO message, and remove the text again with a second EM_UNDO message as long as there is no intervening edit operation.

Rich Edit 2.0 and later: The undo feature is multilevel so sending two EM_UNDO messages will undo the last two operations in the undo queue. To redo an operation, send the EM_REDO message.


GetLastResult

Returns the last result code

FUNCTION GetLastResult () AS HRESULT
   RETURN m_Result
END FUNCTION

SetResult

Sets the last result code.

FUNCTION SetResult (BYVAL Result AS HRESULT) AS HRESULT
   m_Result = Result
   RETURN m_Result
END FUNCTION
ParameterDescription
ResultThe HRESULT error code returned by the methods.

GetErrorInfo

Returns a description of the last result code.

PRIVATE FUNCTION GetErrorInfo (BYVAL nError AS LONG = -1) AS DWSTRING

NewDoc

Opens a new document. If another document is open, this method saves any current changes and closes the current document before opening a new one.

FUNCTION NewDoc () AS HRESULT
Return value

If this method succeeds, it returns S_OK.

Usage example
pRichEdit.NewDoc

OpenDoc

Opens a new document. If another document is open, this method saves any current changes and closes the current document before opening a new one.

FUNCTION OpenDoc (BYVAL pVar AS VARIANT PTR, BYVAL Flags AS LONG = 0, _
   BYVAL CodePage AS LONG = CP_ACP) AS HRESULT
ParameterDescription
pVarA VARIANT that specifies the name of the file to open.
FlagstomRTF: Open as RTF. tomText: Open as text ANSI or Unicode.
CodePageThe code page to use for the file. Zero (the default value) means CP_ACP (ANSI code page) unless the file begins with a Unicode BOM &hfeff, in which case the file is considered to be Unicode. Note that code page 1200 is Unicode, CP_UTF8 is UTF-8.
FlagDescription
tomOpenExistingOpen an existing file. Fail if the file does not exist.
tomOpenAlwaysOpen an existing file. Create a new file if the file does not exist.
tomTruncateExistingOpen an existing file, but truncate it to zero length.
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.

Result codeDescription
S_OKMethod succeeds.
E_INVALIDARGInvalid argument.
E_OUTOFMEMORYInsufficient memory.
E_NOTIMPLFeature not implemented.
Usage example
DIM dv AS DVARIANT = AfxGetExePath & $"\Test.rtf"
pRichEdit.OpenDoc(dv)

SaveDoc

Saves the document.

FUNCTION SaveDoc (BYVAL pVar AS VARIANT PTR, BYVAL Flags AS LONG = tomRTF, _
   BYVAL CodePage AS LONG = CP_ACP) AS HRESULT
ParameterDescription
pVarThe save target. This parameter is a VARIANT, which can be a file name, or NULL. See Remarks.
FlagsFile creation, share, and conversion flags. For a list of possible values, see the tables below.
CodePageThe specified code page. Common values are CP_ACP (zero: system ANSI code page), 1200 (Unicode), and 1208 (UTF-8).

Any combination of these values may be used.

FlagDescription
tomReadOnlyRead only.
tomShareDenyReadOther programs cannot read.
tomShareDenyWriteOther programs cannot write.

These values are mutually exclusive.

FlagDescription
tomCreateNewCreate a new file. Fail if the file already exists.
tomCreateAlwaysCreate a new file. Destroy the existing file if it exists.
tomRTFSave as RTF.
tomTextSave as text.
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.

Result codeDescription
S_OKMethod succeeds.
E_INVALIDARGInvalid argument.
E_OUTOFMEMORYInsufficient memory.
E_NOTIMPLFeature not implemented.
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.

Usage examples

Overwrites the current document in RTF format:

pRichEdit->SaveDoc(BYVAL NULL)
-- or --
pRichEdit->SaveDoc(BYVAL NULL, tomRTF)

Overwrites the current document in text format:

pRichEdit->SaveDoc(BYVAL NULL, tomText)

Overwrites the current document in utf-8 format:

pRichEdit->SaveDoc(BYVAL NULL, tomText, CP_UTF8)

Overwrites the current document in unicode format:

pRichEdit->SaveDoc(BYVAL NULL, tomText, 1200)

Saves the current document in RTF format:

DIM dv AS DVARIANT = AfxGetExePath & $"\Test02.rtf"
pRichEdit->SaveDoc(dv, tomCreateAlways OR tomRTF)

Saves the current document in text format:

DIM dv AS DVARIANT = AfxGetExePath & $"\Test02.txt"
pRichEdit->SaveDoc(dv, tomCreateAlways OR tomText)

Saves the current document in utf-8 (with BOM):

DIM dv AS DVARIANT = AfxGetExePath & $"\Test02.txt"
pRichEdit->SaveDoc(dv, tomCreateAlways OR tomText, CP_UTF8)

Saves the current document in unicode:

DIM dv AS DVARIANT = AfxGetExePath & $"\Test02.txt"
pRichEdit->SaveDoc(dv, tomCreateAlways OR tomText, 1200)

DocName

Gets the path and file name of the document.

PRIVATE FUNCTION DocName () AS DWSTRING
PRIVATE FUNCTION GetDocName () AS DWSTRING
Return value

The path and file name of the document.


GetTextFromFile

Gets text from the specified file

FUNCTION GetTextFromFile (BYREF wszFileName AS WSTRING) AS STRING
ParameterDescription
wszFileNameThe path and name of the file to read.
Return value

An string with the contents of the file or an empty string if the method fails. Possible errors are E_INVALIDARG (invalid argument) and ERROR_FILE_NOT_FOUND (if the file does not exist). Call the GetErrorInfo method to get error information.

Remarks

This method is used by the AppendDocFile and InsertDocFile methods.

AppendDocFile

Appends the contents of the specified file. Besides .rtf files, this method also insert the content of ansi, unicode or utf8 files if you specify the appropriate code page.

FUNCTION AppendDocFile (BYREF wszFileName AS WSTRING, BYVAL CodePage AS DWORD = CP_ACP) AS DWORD
ParameterDescription
wszFileNamePath and name of the RTF file to append.
CodePageThe code page to use for the conversion. Besides the default (CP_ACP), you can use CP_ANSI (ansi), CP_UTF8 (utf8) or 1200 (unicode).
Usage example

Append a RTF file.

IM wszFileName AS WSTRING * MAX_PATH = AfxGetExePath & $"\Test.rtf"
RichEdit->AppendDocFile(wszFileName)

Append a file with ansi contents.

IM wszFileName AS WSTRING * MAX_PATH = AfxGetExePath & $"\Test.txt"
RichEdit->AppendDocFile(wszFileName, 500, CP_ANSI)
-- or --
RichEdit->AppendDocFile(wszFileName, -1, CP_ANSI)

Append a file with utf8 contents.

IM wszFileName AS WSTRING * MAX_PATH = AfxGetExePath & $"\Test.txt"
RichEdit->AppendDocFile(wszFileName, 500, CP_UTF8)
-- or --
RichEdit->AppendDocFile(wszFileName, -1, CP_UTF8)

Append a file with unicode contents.

IM wszFileName AS WSTRING * MAX_PATH = AfxGetExePath & $"\Test.txt"
RichEdit->AppendDocFile(wszFileName, 500, 1200)
-- or --
RichEdit->AppendDocFile(wszFileName, -1, 1200)

InsertDocFile

Inserts the contents of the specified file at the specified location. Besides .rtf files, this method also insert the content of ansi, unicode or utf8 files if you specify the appropriate code page.

FUNCTION InsertDocFile (BYREF wszFileName AS WSTRING, BYVAL dwPos AS DWORD, BYVAL CodePage AS DWORD = CP_ACP) AS DWORD
ParameterDescription
wszFileNamePath and name of the RTF file to insert.
dwPosLocation where to insert the RTF file. If dwPos = -1, the contents of the RTF file are inserted at the caret position.
CodePageThe code page to use for the conversion. Besides the default (CP_ACP), you can use CP_ANSI (ansi), CP_UTF8 (utf8) or 1200 (unicode).
Usage examples

Insert a RTF file.

IM wszFileName AS WSTRING * MAX_PATH = AfxGetExePath & $"\Test.rtf"
RichEdit->InsertDocFile(wszFileName, 500)
-- or --
RichEdit->InsertDocFile(wszFileName, -1)

Insert a file with ansi contents.

IM wszFileName AS WSTRING * MAX_PATH = AfxGetExePath & $"\Test.txt"
RichEdit->InsertDocFile(wszFileName, 500, CP_ANSI)
-- or --
RichEdit->InsertDocFile(wszFileName, -1, CP_ANSI)

Insert a file with utf8 contents.

IM wszFileName AS WSTRING * MAX_PATH = AfxGetExePath & $"\Test.txt"
RichEdit->InsertDocFile(wszFileName, 500, CP_UTF8)
-- or --
RichEdit->InsertDocFile(wszFileName, -1, CP_UTF8)

Insert a file with unicode contents.

IM wszFileName AS WSTRING * MAX_PATH = AfxGetExePath & $"\Test.txt"
RichEdit->InsertDocFile(wszFileName, 500, 1200)
-- or --
RichEdit->InsertDocFile(wszFileName, -1, 1200)

GetRtf

Retrieves RTF formatted text from a Rich Edit control.

FUNCTION GetRtf (BYVAL dwOptionsAndFlags AS DWORD = SF_RTF) AS STRING
ParameterDescription
dwOptionsAndFlagsSpecifies the data format and replacement options.
ValueMeaning
SF_RTFRTF.
SF_RTFNOOBJSRTF with spaces in place of COM objects.
SF_TEXTText with spaces in place of COM objects.
SF_TEXTIZEDText with a text representation of COM objects.

The SF_RTFNOOBJS option is useful if an application stores COM objects itself, as RTF representation of COM objects is not very compact. The control word, \objattph, followed by a space denotes the object position.

In addition, you can specify the following flags.

ValueMeaning
SFF_PLAINRTFIf specified, the rich edit control streams out only the keywords common to all languages, ignoring language-specific keywords. If not specified, the rich edit control streams out all keywords. You can combine this flag with the SF_RTF or SF_RTFNOOBJS flag.
SFF_SELECTIONIf specified, the rich edit control streams out only the contents of the current selection. If not specified, the control streams out the entire contents. You can combine this flag with any of data format values.
SF_UNICODEMicrosoft Rich Edit 2.0 and later: Indicates Unicode text. You can combine this flag with the SF_TEXT flag.
SF_USECODEPAGERich Edit 3.0 and later: Generates UTF-8 RTF and text using other code pages. The code page is set in the high word of dwOptionsAndFlags. For example, for UTF-8 RTF, set dwOptionsAndFlags to (CP_UTF8 << 16) OR SF_USECODEPAGE OR SF_RTF.
Return value

Returns the retrieved text or a null string.


LoadRtfFromFile

Loads the contents of a RTF file into a Rich Edit control. Deprecated and removed. Use OpenDoc instead.

FUNCTION LoadRtfFromFile (BYREF wszFileName AS WSTRING) AS BOOLEAN
ParameterDescription
wszFileNameThe name of the RTF file to load.
Return value

If the operation succeeds, the return value is TRUE. If the operation fails, the return value is FALSE.

Remarks

First you have to create an instance of the CRichEditOleCallback class and pass a pointer to it to the rich edit control using the SetOleCallback method.

DIM pRichEditOleCallback AS CRichEditOleCallback = CRichEditOleCallback
pRichEdit.SetOleCallback(@pRichEditOleCallback)

Then load the .rtf file using the LoadRtfFromFile method.

pRichEdit.LoadRtfFromFile(<path and name of the RTF file>)
e.g. pRichEdit->LoadRtfFromFile(AfxGetExePath & "\Test.rtf")

LoadRtfFromResource

Loads a RTF resource file into a Rich Edit control.

FUNCTION LoadRtfFromResource (BYREF wszResourceName AS WSTRING) AS BOOLEAN
ParameterDescription
wszResourceNameThe name of the resource to load.
Return value

If the operation succeeds, the return value is TRUE. If the operation fails, the return value is FALSE.

Remarks

First you have to create an instance of the CRichEditOleCallback class and pass a pointer to it to the rich edit control using the SetOleCallback method.

DIM pRichEditOleCallback AS CRichEditOleCallback = CRichEditOleCallback
pRichEdit.SetOleCallback(@pRichEditOleCallback)

Then load the .rtf file using the LoadRtfFromResource method.

pRichEdit.LoadRtfFromResource(<resource name>, e.g. RTFILE)

Resource file 1 24 ".\Resources\Manifest.xml" RTFFILE RCDATA ".\Resources\<title of the rtf file>.rtf"


SetFont

Sets the font used by a rich edit control.

FUNCTION SetFont (BYREF wszFaceName AS WSTRING, BYVAL ptsize AS LONG) AS HRESULT
ParameterDescription
wszFaceNameThe font name.
ptsizeThe font size in points.
Return value

If the operation succeeds, the return value is a nonzero value. If the operation fails, the return value is zero.


AddLF/AddCR/AddCRLF

Inserts a line feed, a carriage return or a carriage return and line feed at the cursor position or at the end of the text.

SUB AddLF (BYVAL atEnd AS BOOLEAN = FALSE)
SUB AddCR (BYVAL atEnd AS BOOLEAN = FALSE)
SUB AddCRLF (BYVAL atEnd AS BOOLEAN = FALSE)
ParameterDescription
atEndOptional. Boolean true (-1) or false (0). If true, the character is added at the end of the text; if false, it is added at the cursor position.

SaveRtf

Saves the contents of the rich edit control to a file in rtf format.

FUNCTION SaveRtf (BYREF wszFilename AS WSTRING, BYVAL Overwrite AS BOOLEAN = FALSE, _
BYVAL dwFlagsAndAttributes AS DWORD = FILE_ATTRIBUTE_NORMAL) AS BOOLEAN
ParameterDescription
wszFilenamePath and file name of the file where the RTF content will be saved.
OverwriteIf true, the file will be overwritten if it already exists and the function will return true; if false, the file will not be overwritten, the function will return false and GetLastResult" will return the **ERROR_ALREADY_EXISTS error.
dwFlagsAndAttributesThe file or device attributes and flags. Default is FILE_ATTRIBUTE_NORMAL, which is the most common default value for files. To see more options see CreateFileW
Return value

Boolean true on success or false on failure.


SaveRtfNoObjs

Saves the contents of the rich edit control to a file in rtf format with spaces in place of COM objects.

For parameters and return values see the SaveRtf method.


SaveSelRtf

Saves selection of the rich edit control to a file in rtf format.

For parameters and return values see the SaveRtf method.


SaveText

Saves the contents of the rich edit control in text format.

For parameters and return values see the SaveRtf method.


SaveSelText

Saves selection of the rich edit control in text format.

For parameters and return values see the SaveRtf method.


IsTextBold

Checks if the selected text or the word under the cursor is bolded.

FUNCTION IsTextBold () AS BOOLEAN
Return value

Boolean true (-1) or false (0).


IsTextItalic

Checks if the selected text or the word under the cursor is italicised.

FUNCTION IsTextItalic () AS BOOLEAN
Return value

Boolean true (-1) or false (0).


IsTextStrikeOut

Checks if the selected text or the word under the cursor is striked out.

FUNCTION IsTextStrikeOut () AS BOOLEAN
Return value

Boolean true (-1) or false (0).


IsTextUnderline

Checks if the selected text or the word under the cursor is underlined.

FUNCTION IsTextUnderline () AS BOOLEAN
Return value

Boolean true (-1) or false (0).


SetTextBold

Changes the selected text or word under the cursor to bold. If it is already set, it removes it.

SUB SetTextBold ()

SetTextItalic

Changes the selected text or word under the cursor to italic. If it is already set, it removes it.

SUB SetTextItalic ()

SetTextStrikeOut

Changes the selected text or word under the cursor to strike out. If it is already set, it removes it.

SUB SetTextStrikeOut ()

SetTextUnderline

Changes the selected text or word under the cursor to underline. If it is already set, it removes it.

SUB SetTextUderline ()

TextColor

Gets/sets the color of the selected text or the word under the cursor.

(GET) PROPERTY TextColor () AS COLORREF
(SET) PROPERTY TextColor (BYVAL crTxtColor AS COLORREF)
FUNCTION GetTextColor () AS COLORREF
FUNCTION SetTextColor (BYVAL crTxtColor AS COLORREF) AS BOOLEAN
ParameterDescription
crTxtColorThe new text color. Use the macro RGB (BGR in FreeBasic), e.g. BGR(255,0,0).
Return value

(GET) The color of the selected text or the word under the cursor if there is not selection.

(SET) A boolean true (-1) or false (0).

Remarks

To select text programatically, use the SetSel method.


TextFontName

Gets/sets the font face name of the selected text or the word under the cursor if there is not selection.

(GET) PROPERTY TextFontName () AS DWSTRING
(SET) PROPERTY TextFontName (BYREF wszFaceName AS WSTRING)
FUNCTION GetTextFontName () AS DWSTRING
FUNCTION SetTextFontName (BYREF wszFaceName AS WSTRING) AS BOOLEAN
ParameterDescription
wszFaceName(SET) The new font face name, e.g. "Times New Roman".
Return value

(GET) The font face name.

(SET) A boolean true (-1) or false (0).

Remarks

To select text programatically, use the SetSel method.


TextHeight

Gets/sets the height of the selected text or the word under the cursor.

(GET) PROPERTY TextHeight () AS LONG
(SET) PROPERTY TextHeight (BYVAL ptSize AS LONG)
FUNCTION GetTextHeight () AS LONG
FUNCTION SetTextHeight (BYVAL ptSize AS LONG) AS BOOLEAN
ParameterDescription
ptSizeThe new text height in points.
Return value

(GET) The height of the selected text or the word under the cursor if there is not selection.

Remarks

To select text programatically, use the SetSel method.


TextOffset

Gets/sets the offset of the selected text or the word under the cursor.

(GET) PROPERTY TextOffset () AS LONG
(SET) PROPERTY TextOffset (BYVAL offset AS LONG)
FUNCTION GetTextOffset () AS LONG
FUNCTION SetTextOffset (BYVAL offset AS LONG) AS BOOLEAN
ParameterDescription
offsetCharacter offset, in pixels, from the baseline. If the value of this member is positive, the character is a superscript; if it is negative, the character is a subscript.
Return value

(GET) The offset of the selected text or the word under the cursor if there is not selection.

(SET) A boollean true (-1) or false (0).

Remarks

This property converts the pixels to twips internally.

To select text programatically, use the SetSel method.


GetDocumentInterface

Retrieves a pointer to the ITextDocument2 interface.

FUNCTION GetDocumentInterface () AS ITextDocument2 PTR
Return value

A pointer to the ITextDocument2 interface. When you have finished to use it, you must release it calling its Release method.

Usage example
DIM pTextDoc AS ITExtDocument2 PTR
pTextDoc = pRichEdit.GetDocumentInterface
...
...
' // Release the pointer
IUnknown_Release(pTextDoc)

AttachMsgFilter

Attaches a new message filter to the edit instance. All window messages that the edit instance receives are forwarded to the message filter.

FUNCTION AttachMsgFilter (BYVAL pFilter AS IUnknown PTR) AS HRESULT
ParameterDescription
pFilterThe message filter.
Return value

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.

Remarks

The message filter must be bound to the document before it can be used.


BeginEditCollection

Turns on edit collection (also called undo grouping).

FUNCTION BeginEditCollection () AS HRESULT
Return value

If the method succeeds, it returns S_OK. If the method fails, it returns one of the following COM error codes: S_FALSE (undo is not enabled), E_NOTIMPL (this method is not implemented).


EndEditCollection

Turns off edit collection (also called undo grouping).

FUNCTION EndEditCollection () AS HRESULT
Return value

If the method succeeds, it returns S_OK. If the method fails, it returns E_NOTIMPL (this method is not implemented).

Remarks

The screen is unfrozen unless the freeze count is nonzero.


CaretType

Gets/sets the caret type.

(GET) PROPERTY CaretType () AS LONG
(SET) PROPERTY CaretType (BYVAL Value AS LONG) AS HRESULT
FUNCTION GetCaretType () AS LONG
FUNCTION SetCaretType (BYVAL Value AS LONG) AS HRESULT
ParameterDescription
ValueThe caret type. It can be one of the following values:
ValueDescription
tomKoreanBlockCaretThe Korean block caret.
tomNormalCaretNormal caret.
tomNullCaretNULL caret (caret suppressed).
Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code. Call GetErrorInfo to get information about the result.


CheckTextLimit

Checks whether the number of characters to be added would exceed the maximum text limit.

FUNCTION CheckTextLimit (BYVAL cch AS LONG) AS LONG
ParameterDescription
cchThe number of characters to be added.
Return value

The number of characters that exceed the maximum text limit. This parameter is 0 if the number of characters does not exceed the limit.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


DefaultTabStop

Gets/sets the default tab width. Default value is 36.0 points, that is, 0.5 inches.

(GET) PROPERTY DefaultTabStop () AS SINGLE
(SET) PROPERTY DefaultTabStop (BYVAL Value AS SINGLE)
FUNCTION GetDefaultTabStop () AS SINGLE
FUNCTION SetDefaultTabStop (BYVAL Value AS SINGLE = 36.0) AS HRESULT
ParameterDescription
ValueNew default tab setting, in floating-point points. Default value is 36.0 points, that is, 0.5 inches.
Result code

If the method succeeds it returns S_OK. If the method fails, it returns E_INVALIDARG (invalid argument) or E_OUTOFMEMORY (insufficient memory.).

Remarks

The default tab width is used whenever no tab exists beyond the current display position. The default width is given in floating-point points.

DocumentFont

Gets/sets a pointer to the ITextFont2 interface.

(GET) PROPERTY DocumentFont () AS ITextFont2 PTR
(SET) PROPERTY DocumentFont (BYVAL pFont AS ITextFont2 PTR)
FUNCTION GetDocumentFont () AS ITextFont2 PTR
FUNCTION SetDocumentFont (BYVAL pFont AS ITextFont2 PTR) AS HRESULT
Return value

A pointer to the ITextFont2 interface. When you have finished to use it, you must release it calling its Release method.

Usage example
DIM pTextFont AS ITExtFont2 PTR
pTextFont = pRichEdit.DocumentFont
--or--
pTextFont = pRichEdit.GetDocumentFont
...
...
' // Release the pointer
IUnknown_Release(pTextFont)

DocumentPara

Gets/sets an object that provides the default paragraph format information for this instance of the Text Object Model (TOM) engine.

(GET) PROPERTY DocumentPara () AS ITextPara2 PTR
(SET) PROPERTY DocumentPara (BYVAL pTextPara AS ITextPara2 PTR)
FUNCTION GetDocumentPara () AS ITextPara2 PTR
FUNCTION SetDocumentPara (BYVAL pTextPara AS ITextPara2 PTR) AS HRESULT
Return value

A pointer to the ITextPara2 interface. When you have finished to use it, you must release it calling its Release method.


EastAsianFlags

Gets the East Asian flags.

FUNCTION EastAsianFlags () AS LONG
FUNCTION GetEastAsianFlags () AS LONG
Return value

The East Asian flags. This parameter can be a combination of the following values.

ValueMeaning
tomRE10ModeTOM version 1.0 emulation mode.
tomUseAtFontUse @ fonts for CJK vertical text.
tomTextFlowMaskA mask for the following four text orientations:
tomTextFlowES
Ordinary left-to-right horizontal text.
tomTextFlowSW
Ordinary East Asian vertical text.
tomTextFlowWN
An alternative orientation.
tomTextFlowNE
An alternative orientation.
tomUsePasswordUse password control.
tomNoIMETurn off IME operation (see ES_NOIME).
tomSelfIMEThe rich edit host handles IME operation (see ES_SELFIME).
Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


Freeze

Increments the freeze count.

FUNCTION Freeze () AS LONG
Return value

The updated freeze count.

Result code

If the Freeze count is nonzero, it returns S_OK. If the Freeze count is zero, it returns FALSE.

Remarks

If the freeze count is nonzero, screen updating is disabled. This allows a sequence of editing operations to be performed without the performance loss and flicker of screen updating. To decrement the freeze count, call the Unfreeze method.


Unfreeze

Decrements the freeze count.

FUNCTION Unfreeze () AS LONG
Return value

The updated freeze count.

Result code

If the freeze count is zero, the method returns S_OK. If the method fails, it returns S_FALSE, indicating that the freeze count is nonzero.

Remarks

If the freeze count goes to zero, screen updating is enabled. This method cannot decrement the count below zero, and no error occurs if it is executed with a zero freeze count.

Note, if edit collection is active, screen updating is suppressed, even if the freeze count is zero.


GetCallManager

Gets the call manager.

FUNCTION GetCallManager () AS IUnknown PTR
Return value

Gets the call manager.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.

Remarks

The call manager object is opaque to the caller. The Text Object Model (TOM) engine uses the object to handle internal notifications for particular scenarios.


ReleaseCallManager

Releases the call manager.

FUNCTION ReleaseCallManager (BYVAL pVoid AS IUnknown PTR) AS HRESULT
ParameterDescription
pVoidThe call manager object to release.
Return value

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


GetDisplays

Gets the displays collection for this Text Object Model (TOM) engine instance.

FUNCTION GetDisplays () AS ITextDisplays PTR
Return value

A pointer to the displays collection.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.

Remarks

The rich edit control doesn't implement this method.


Range

Retrieves a new text range for the active story of the document.

FUNCTION Range (BYVAL cpActive AS LONG = 0, BYVAL cpAnchor AS LONG = 0) AS ITextRange2 PTR
ParameterDescription
cpActiveThe active end of the new text range. The default value is 0; that is, the beginning of the story.
cpAnchorThe anchor end of the new text range. The default value is 0.
Return value

A ITextRange2 pointer to the specified text range.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code. Call GetErrorInfo to get information about the result.


RangeFromPoint

Retrieves the degenerate range at (or nearest to) a particular point on the screen.

FUNCTION RangeFromPoint (BYVAL x AS LONG, BYVAL y AS LONG, BYVAL nType AS LONG) AS ITextRange2 PTR
ParameterDescription
xThe horizontal coordinate of the specified point, in screen coordinates.
yThe vertical coordinate of the specified point, in screen coordinates.
nTypeThe alignment type of the specified point. For a list of valid values, see ITextRange.GetPoint.
Return value

The text range that corresponds to the specified point.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


GetStoryRanges

Gets the story collection object used to enumerate the stories in a document.

FUNCTION GetStoryRanges () AS ITextStoryRanges PTR
Return value

The ITextStoryRanges pointer. It can be null if there is only one story in this document.

Result code

If the method succeeds, it returns S_OK. If the method fails, it returns E_NOTIMPL (not implemented; only one story in this document).


GetStoryRanges2

Gets an object for enumerating the stories in a document.

FUNCTION GetStoryRanges2 () AS ITextStoryRanges2 PTR
Return value

The object for enumerating stories.

Result code

If the method succeeds, it returns S_OK. If the method fails, it returns E_NOTIMPL (not implemented; only one story in this document).

Remarks

Call this method only if the GetStoryCount method returns a value that is greater than one.


Saved

Gets/sets a value that indicates whether changes have been made since the file was last saved.

(GET) PROPERTY Saved () AS BOOLEAN
(SET) PROPERTY Saved (BYVAL value AS BOOLEAN)
FUNCTION GetSaved () AS BOOLEAN
FUNCTION SetSaved (BYVAL value AS BOOLEAN) AS HRESULT
ParameterDescription
valueThe value tomTrue if no changes have been made since the file was last saved, or the value tomFalse if there are unsaved changes.
Return value

(GET) The value tomTrue if no changes have been made since the file was last saved, or the value tomFalse if there are unsaved changes.

Result code

(SET) If the method succeeds, it returns S_OK. If the method fails, it returns E_INVALIDARG (invalid argument). Call GetErrorInfo to get information about the result.


Selection

Gets the active selection.

PRIVATE FUNCTION Selection () AS ITextSelection PTR
PRIVATE FUNCTION GetSelection () AS ITextSelection PTR
Return value

The active selection. It will be null if there is not active selection.

Result code

If the method succeeds, it returns S_OK. If there is not active selection, it returns S_FALSE. Call GetErrorInfo to get information about the result.


Selection2

Gets the active selection.

PRIVATE FUNCTION Selection2 () AS ITextSelection PTR
PRIVATE FUNCTION GetSelection2 () AS ITextSelection PTR
Return value

The active selection. It will be NULL if the rich edit control is not in-place active.

Result code

If the method succeeds, it returns S_OK. If there is not active selection, it returns S_FALSE. Call GetErrorInfo to get information about the result.


StoryCount

Gets the number of stories in the document.

DECLARE FUNCTION StoryCount () AS LONG
DECLARE FUNCTION GetStoryCount () AS LONG
Return value

The number of stories in the document.

Result code

If the method succeeds, it returns S_OK. Call GetErrorInfo to get information about the result.


GetClientRect

Retrieves the client rectangle of the rich edit control.

FUNCTION GetClientRect (BYVAL nType AS LONG, BYREF Left AS LONG, BYREF Top AS LONG,_
   BYREF Right AS LONG, BYREF Bottom AS LONG) AS HRESULT
FUNCTION GetClientRect (BYVAL nType AS LONG) AS .RECT
ParameterDescription
nTypeThe client rectangle retrieval options. It can be a combination of the following values:
tomClientCoord: Retrieve the rectangle in client coordinates. If this value isn't specified, the function retrieves screen coordinates.
tomIncludeInset:Add left and top insets to the left and top coordinates of the client rectangle, and subtract right and bottom insets from the right and bottom coordinates.
tomTransform: Use a world transform (XFORM) provided by the host application to transform the retrieved rectangle coordinates.
LeftThe x-coordinate of the upper-left corner of the rectangle.
TopThe y-coordinate of the upper-left corner of the rectangle.
RightThe x-coordinate of the lower-right corner of the rectangle.
BottomThe y-coordinate of the lower-right corner of the rectangle.
Return value

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.

The second overlapped structure returns a RECT structure.


EffectColor

Retrieves the color used for special text attributes.

(GET) PROPERTY EffectColor (BYVAL Index AS LONG) AS ULONG
(SET) PROPERTY EffectColor (BYVAL Index AS LONG, BYVAL Value AS ULONG)
FUNCTION GetEffectColor (BYVAL Index AS LONG) AS ULONG
FUNCTION SetEffectColor (BYVAL Index AS LONG, BYVAL Value AS ULONG) AS HRESULT
ParameterDescription
IndexThe index of the color to retrieve. It can be one of the following values:
IndexMeaning
0Text color.
1RGB(0, 0, 0)
2RGB(0, 0, 255)
3RGB(0, 255, 255)
4RGB(0, 255, 0)
5RGB(255, 0, 255)
6RGB(255, 0, 0)
7RGB(255, 255, 0)
8RGB(255, 255, 255)
9RGB(0, 0, 128)
10RGB(0, 128, 128)
11RGB(0, 128, 0)
12RGB(128, 0, 128)
13RGB(128, 0, 0)
14RGB(128, 128, 0)
15RGB(128, 128, 128)
16RGB(192, 192, 192)
ParameterDescription
ValueThe new color for the specified index.
Return value

(GET) The color that corresponds to the specified index.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.

Remarks

The first 16 index values are for special underline colors. If an index between 1 and 16 hasn't been defined by a call to the SetEffectColor method, GetEffectColor returns the corresponding Microsoft Word default color.


GetGenerator

Gets the name of the Text Object Model (TOM) engine.

FUNCTION GetGenerator () AS DWSTRING
Return value

The name of the TOM engine.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


GetImmContext

Gets the Input Method Manager (IMM) input context from the Text Object Model (TOM) host.

FUNCTION GetImmContext () AS __int64
Return value

The IMM input context.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


ReleaseImmContext

Releases an Input Method Manager (IMM) input context.

FUNCTION ReleaseImmContext (BYVAL Context AS __int64) AS HRESULT
ParameterDescription
ContextThe IMM input context to release.
Return value

The IMM input context.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


GetPreferredFont

Retrieves the preferred font for a particular character repertoire and character position.

PRIVATE FUNCTION GetPreferredFont (BYVAL cp AS LONG, BYVAL CharRep AS LONG, _
   BYVAL nOptions AS LONG, BYVAL curCharRep AS LONG, BYVAL curFontSize AS LONG, _
   BYVAL fontName AS AFX_BSTR PTR, BYREF PitchAndFamily AS LONG, BYREF NewFontSize AS LONG) AS HRESULT
ParameterDescription
cpThe character position for the preferred font.
CharRepThe character repertoire index for the preferred font. It can be one of the following values.
tomAboriginal, tomAnsi, tomArabic, tomArmenian, tomBaltic, tomBengali, tomBIG5, tomBraille, tomCherokee, tomCyrillic, tomDefaultCharRep, tomDevanagari, tomEastEurope, tomEmoji, tomEthiopic, tomGB2312, tomGeorgian, tomGreek, tomGujarati, tomGurmukhi, tomHangul, tomHebrew, tomJamo, tomKannada, tomKayahli, tomKharoshthi, tomKhmer, tomLao, tomLimbu, tomMac, tomMalayalam, tomMongolian, tomMyanmar, tomNewTaiLu, tomOEM, tomOgham, tomOriya, tomPC437, tomRunic, tomShiftJIS, tomSinhala, tomSylotinagr, tomSymbol, tomSyriac, tomTaiLe, tomTamil, tomTelugu, tomThaana, tomThai, tomTibetan, tomTurkish, tomUsymbol, tomVietnamese, tomYi.
nOptionsThe preferred font options. The low-order word can be a combination of the following values: tomIgnoreCurrentFont, tomMatchCharRep, tomMatchFontSignature, tomMatchAscii, tomGetHeightOnly, tomMatchMathFont. If the high-order word of Options is tomUseTwips, the font heights are given in twips.
curCharRepThe index of the current character repertoire.
curFontSizeThe current font size.
fontNameThe name of the font.
PitchAndFamilyThe font pitch and family.
NewFontSizeThe new font size.
Return value

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


GetProperty

Retrieves the value of a property.

FUNCTION GetProperty (BYVAL nType AS LONG) AS LONG
ParameterDescription
nTypeThe identifier of the property to retrieve. It can be one of the following property IDs: tomCanCopy, tomCanRedo, tomCanUndo, tomDocMathBuild, tomMathInterSpace, tomMathIntraSpace, tomMathLMargin, tomMathPostSpace, tomMathPreSpace, tomMathRMargin, tomMathWrapIndent, tomMathWrapRight, tomUndoLimit, tomEllipsisMode, tomEllipsisState.
Return value

The value of the property.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code. Call GetErrorInfo to get information about the result.


SetProperty

Specifies a new value for a property.

FUNCTION SetProperty (BYVAL nType AS LONG, BYVAL Value AS LONG) AS HRESULT
ParameterDescription
nTypeThe identifier of the property. It can be one of the following property IDs: tomCanCopy, tomCanRedo, tomCanUndo, tomDocMathBuild, tomMathInterSpace, tomMathIntraSpace, tomMathLMargin, tomMathPostSpace, tomMathPreSpace, tomMathRMargin, tomMathWrapIndent, tomMathWrapRight, tomUndoLimit, tomEllipsisMode, tomEllipsisState.
ValueThe new property value.
Return value

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code. Call GetErrorInfo to get information about the result.


GetStory

Retrieves the story that corresponds to a particular index.

FUNCTION GetStory (BYVAl Index AS LONG) AS ITextStory PTR
ParameterDescription
IndexThe index of the story to retrieve.
Return value

A pointer to the ITextStory interface.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


ActiveStory

Gets/sets the active story; that is, the story that receives keyboard and mouse input.

(GET) PROPERTY ActiveStory () AS ITextStory PTR
(SET) PROPERTY ActiveStory (BYVAL pStory AS ITextStory PTR)
FUNCTION GetActiveStory () AS ITextStory PTR
FUNCTION SetActiveStory (BYVAL pStory AS ITextStory PTR) AS HRESULT
Return value

A pointer to the ITextStory interface of the active story.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


MainStory

Gets the main story.

FUNCTION MainStory () AS ITextStory PTR
FUNCTION GetMainStory (BYVAL pStory AS ITextStory PTR) AS HRESULT
Return value

A pointer to the ITextStory interface of the main story.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


NewStory

Not implemented. Gets a new story.

FUNCTION NewStory () AS ITextStory PTR
FUNCTION GetNewStory (BYVAL pStory AS ITextStory PTR) AS HRESULT
Return value

A pointer to the ITextStory interface of the new story.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


GetStrings

Gets a collection of rich-text strings.

FUNCTION GetStrings () AS ITextStrings PTR
Return value

A pointer to the collection of rich-text strings.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.

Remarks

The collection is useful for manipulating rich text, particularly for transforming mathematical text from linear to built-up form, or vice versa.


GetWindow

Gets the handle of the window that the Text Object Model (TOM) engine is using to display output.

FUNCTION FUNCTION GetWindow () AS __int64
Return value

The handle of the window that the TOM engine is using.

Result code

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


SetIMEInProgress

Sets the state of the Input Method Editor (IME) in-progress flag.

FUNCTION SetIMEInProgress (BYVAL Value AS LONG) AS HRESULT
ParameterDescription
ValueUse tomTrue to turn on the IME in-progress flag, or tomFalse to turn it off.
Return value

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


MathProperties

Gets/sets the math properties for the document.

PROPERTY MathProperties () AS LONG
PROPERTY MathProperties (BYVAL nOptions AS LONG, BYVAL Mask AS LONG)
FUNCTION GetMathProperties () AS LONG
FUNCTION SetMathProperties (BYVAL Options AS LONG, BYVAL Mask AS LONG) AS HRESULT
ParameterDescription
nOptionsA combination of math properties. See table below.
MaskThe math mask. See table below.
PropertyMeaning
tomMathDispAlignMaskDisplay-mode alignment mask.
tomMathDispAlignCenterCenter (default) alignment.
tomMathDispAlignLeftLeft alignment.
tomMathDispAlignRightRight alignment.
tomMathDispIntUnderOverDisplay-mode integral limits location.
tomMathDispFracTeXDisplay-mode nested fraction script size.
tomMathDispNaryGrowMath-paragraph n-ary grow.
tomMathDocEmptyArgMaskEmpty arguments display mask.
tomMathDocEmptyArgAutoAutomatically use a dotted square to denote empty arguments, if necessary.
tomMathDocEmptyArgAlwaysAlways use a dotted square to denote empty arguments.
tomMathDocEmptyArgNeverDon't denote empty arguments.
tomMathDocSbSpOpUnchangedDisplay the underscore (_) and caret (^) as themselves.
tomMathDocDiffMaskStyle mask for the tomMathDocDiffUpright, tomMathDocDiffItalic, tomMathDocDiffOpenItalic options.
tomMathDocDiffItalicUse italic (default) for math differentials.
tomMathDocDiffUprightUse an upright font for math differentials.
tomMathDocDiffOpenItalicUse open italic (default) for math differentials.
tomMathDispNarySubSupMath-paragraph non-integral n-ary limits location.
tomMathDispDefMath-paragraph spacing defaults.
tomMathEnableRtlEnable right-to-left (RTL) math zones in RTL paragraphs.
tomMathBrkBinMaskEquation line break mask.
tomMathBrkBinBeforeBreak before binary/relational operator.
tomMathBrkBinAfterBreak after binary/relational operator.
tomMathBrkBinDupDuplicate binary/relational before/after.
tomMathBrkBinSubMaskDuplicate mask for minus operator.
tomMathBrkBinSubMM- - (minus on both lines).
tomMathBrkBinSubPM+ -
tomMathBrkBinSubMP- +
Return value

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


NotificationMode

Gets/sets the notification mode.

(GET) PROPERTY NotificationMode () AS LONG
(SET) PROPERTY NotificationMode (BYVAL Value AS LONG)
FUNCTION GetNotificationMode () AS LONG
FUNCTION SetNotificationMode (BYVAL Value AS LONG) AS HRESULT
ParameterDescription
ValueThe notification mode. This parameter is set to tomTrue if notifications are active, or tomFalse if not.
Return value

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


Notify

Notifies the Text Object Model (TOM) engine client of particular Input Method Editor (IME) events.

FUNCTION Notify (BYVAL nNotify AS LONG) AS HRESULT
ParameterDescription
nNotifyAn IME notification code.
Return value

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


SysBeep

Generates a system beep.

FUNCTION SysBeep () AS HRESULT
Return value

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


Update

Updates the selection and caret.

FUNCTION Update (BYVAL Value AS LONG) AS HRESULT
ParameterDescription
ValueScroll flag. Use tomTrue to scroll the caret into view.
Return value

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.


UpdateWindow

Notifies the client that the view has changed and the client should update the view if the Text Object Model (TOM) engine is in-place active.

FUNCTION UpdateWindow () AS HRESULT
Return value

If the method succeeds, it returns NOERROR. Otherwise, it returns an HRESULT error code.