ITfRange::AdjustForInsert method (msctf.h)

The ITfRange::AdjustForInsert method expands or contracts a range of text to adjust for text insertion.

Syntax

HRESULT AdjustForInsert(
  [in]  TfEditCookie ec,
  [in]  ULONG        cchInsert,
  [out] BOOL         *pfInsertOk
);

Parameters

[in] ec

Edit cookie obtained from ITfDocumentMgr::CreateContext or ITfEditSession::DoEditSession.

[in] cchInsert

Character count of the inserted text. This count is used in a futurecall to ITfRange::SetText. If the character count is unknown, 0 can be used.

[out] pfInsertOk

Pointer to a flag that indicates whether the context owner will accept (TRUE) or reject (FALSE) the insertion.

Return value

This method can return one of these values.

Value Description
S_OK
The method was successful.
E_FAIL
The method failed.
E_INVALIDARG
One or more parameters are invalid.
E_NOTIMPL
The application was unable to replace the selection.
TF_E_NOLOCK
The value in the ec parameter is an invalid cookie, or the caller does not have a read-only lock.

Remarks

This method should be used to prepare a range to initiate a new composition, before editing begins. It should be used only when the text is not inserted at the current selection. ITFInsertAtSelection:InsertTextAtSelection or ITfInsertAtSelection::InsertEmbeddedAtSelection are the correct methods to use when text is inserted at the current selection.

The context owner can use this method to preserve behavior and help maintain a consistent user experience. For example, certain characters or objects in the context can be preserved from modifications, or overtyping can be supported.

This method is not necessary when modifying an existing composition. It is acceptable to call ITfRange::SetText directly to modify text previously entered by the caller.

On exit, if *pfInsertOk is set to FALSE, a future call to ITfRange::SetText or ITfRange::InsertEmbedded with this range is likely to fail. Otherwise, *pfInsertOk will be set to TRUE, and the range start anchor or end anchor can be repositioned at the discretion of the context owner.

Requirements

   
Minimum supported client Windows 2000 Professional [desktop apps | UWP apps]
Minimum supported server Windows 2000 Server [desktop apps | UWP apps]
Target Platform Windows
Header msctf.h
DLL Msctf.dll
Redistributable TSF 1.0 on Windows 2000 Professional

See also

ITFInsertAtSelection:InsertTextAtSelection

ITfDocumentMgr::CreateContext

ITfEditSession::DoEditSession

ITfInsertAtSelection::InsertEmbeddedAtSelection

ITfRange

ITfRange::InsertEmbedded

ITfRange::SetText

Text Stores