ITextSelection::TypeText method

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 SendMessagefunction, 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

   
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