ITextSelection::TypeText method (tom.h)

Types the string given by bstr at this selection as if someone typed it. This is similar to the underlying SetText method, but is sensitive to the Insert/Overtype key state and UI settings like AutoCorrect and smart quotes.

Syntax

HRESULT TypeText(
  BSTR bstr
);

Parameters

bstr

Type: BSTR

String to type into this selection.

Return value

Type: HRESULT

The method returns an HRESULT value. If the method succeeds, it returns S_OK. If the method fails, it returns one of the following error codes. For more information about COM error codes, see Error Handling in COM.

Return code Description
E_ACCESSDENIED
Text is write-protected.
E_INVALIDARG
bstr is null.
E_OUTOFMEMORY
Out of memory.

Remarks

This method types the string given by bstr at this selection as if someone typed it. Using TypeText is faster than sending characters through the SendMessage function, but it is slower than using SetText.

TypeText is similar to the underlying SetText method, however, it is sensitive to the Insert/Overtype key state and UI settings like AutoCorrect and smart quotes. For example, it deletes any nondegenerate selection and then inserts or overtypes (depending on the Insert/Overtype key state—see the SetFlags method) the string bstr at the insertion point, leaving this selection as an insertion point following the inserted text.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header tom.h
DLL Msftedit.dll

See also

Conceptual

ITextSelection

Other Resources

Reference

SendMessage

SetFlags

SetText

Text Object Model