Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

ITextStoreAnchor::SetText method

The ITextStoreAnchor::SetText method sets the text selection between two supplied anchor locations.

Syntax


HRESULT SetText(
  [in]  DWORD dwFlags,
  [in]  IAnchor *paStart,
  [in]  IAnchor *paEnd,
  [in]  const WCHAR *pchText,
  [in]  ULONG cch
);

Parameters

dwFlags [in]

If set to the value of TS_ST_CORRECTION, the text is a transform (correction) of existing content, and any special text markup information (metadata) is retained, such as .wav file data or a language identifier. The client defines the type of markup information to be retained.

paStart [in]

Pointer to the anchor at the start of the range of text to replace.

paEnd [in]

Pointer to the anchor at the end of the range of text to replace. Must always follow or be at the same position as paStart.

pchText [in]

Pointer to the replacement text. The text string does not have to be NULL terminated, because the text character count is specified in the cch parameter.

cch [in]

Specifies the number of characters in the replacement text.

Return value

This method can return one of these values.

ValueDescription
S_OK

The method was successful.

E_FAIL

The method could not instantiate one of the anchors paStart or paEnd.

TS_E_INVALIDPOS

The location of paStart or paEnd is outside of the document text.

TS_E_NOLOCK

The caller does not have a read/write lock.

TS_E_READONLY

The document is read-only. Content cannot be modified.

TS_E_REGION

An attempt was made to modify text across a region boundary.

 

Remarks

Applications should start a composition by first using ITextStoreAnchor::InsertTextAtSelection. ITextStoreAnchor::SetText should be used only within an existing composition. If there is no active composition at the time SetText is called, the TSF manager creates a composition that lasts just long enough to wrap the call to SetText.

Callers must hold a write lock obtained through ITextStoreAnchor::RequestLock. Otherwise, ITextStoreAnchor::SetText will fail with TS_E_NOLOCK.

If paStart is at the same location as paEnd, then the operation is an insertion, and no existing text will be removed.

TS_CHAR_EMBEDDED cannot be passed into this method. For embedded objects, use ITextStoreAnchor::InsertEmbedded instead.

This method will fail if the range of text replaced covers any region boundary. Instead, callers should make multiple calls to the method, one for each region.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps | Windows Store apps]

Minimum supported server

Windows 2000 Server [desktop apps | Windows Store apps]

Redistributable

TSF 1.0 on Windows 2000 Professional

Header

Textstor.h

IDL

Textstor.idl

DLL

Msctf.dll

See also

ITextStoreAnchor
ITextStoreAnchor::RequestLock
ITextStoreAnchor::InsertEmbedded
ITextStoreAnchorSink::OnTextChange
Miscellaneous Text Store Constants
Embedded Objects
Compositions

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.