private void InsertTextAtSelection(uint ec, ITfContext pContext, string pchText, int cchText) { // we need a special interface to insert text at the selection var pInsertAtSelection = (ITfInsertAtSelection)pContext; // insert the text ITfRange pRange = pInsertAtSelection.InsertTextAtSelection(ec, 0, pchText, cchText); // update the selection, we'll make it an insertion point just past the inserted text. pRange.Collapse(ec, TfAnchor.TF_ANCHOR_END); var tfSelection = new TF_SELECTION[] { new TF_SELECTION { range = pRange, style = new TF_SELECTIONSTYLE { ase = TfActiveSelEnd.TF_AE_NONE, fInterimChar = false } } }; pContext.SetSelection(ec, 1, tfSelection); }
public override HRESULT DoEditSession([In] uint ec) { // get the head of the doc var tfSelection = new TF_SELECTION[1]; try { pContext.GetSelection(ec, TF_DEFAULT_SELECTION, 1, tfSelection, out var cFetched); if (cFetched == 0) { return(HRESULT.S_OK); } } catch { return(HRESULT.S_OK); } // do the work ToggleCase(ec, tfSelection[0].range, false); return(HRESULT.S_OK); }