locked
why I am unable to insert text after insertion?

    Question

  • I want to insert some characters after insertion,but the text inserted is before insertion.

    the code segment :

    ......//ignore some codes and definitioans

      ITfContext *pContext=GetContext();//GetContext is custom-function.
      ITfRange* range(NULL);
      wchar_t *pTxBuf=m_ImeData->TxBuffer;

      hr=pContext->GetSelection(ec,TF_DEFAULT_SELECTION,1,&ts,&nSels);
      
      if( SUCCEEDED(hr) )
      {
       range=ts.range;
       TF_SELECTION ts={0};
       ULONG nSels(0); 
       ULONG len=wcslen(pTxBuf);
       LONG n(0);
       hr=range->SetGravity(ec,TF_GRAVITY_FORWARD,TF_GRAVITY_FORWARD);
       hr=range->SetText(ec,TF_ST_CORRECTION,pTxBuf,len);
          
      }...

    Friday, September 07, 2012 9:03 AM

Answers

  • You are getting the beginning of the selection and then replacing that range. If you want to set the text at the end of the selection then collapse your range to the end of the selection.

    --Rob

    Tuesday, September 11, 2012 12:01 AM
    Owner