本文整理汇总了C++中ITfRange::SetText方法的典型用法代码示例。如果您正苦于以下问题:C++ ITfRange::SetText方法的具体用法?C++ ITfRange::SetText怎么用?C++ ITfRange::SetText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITfRange
的用法示例。
在下文中一共展示了ITfRange::SetText方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoEditSession
STDAPI CEndCompositionEditSession::DoEditSession(TfEditCookie ec)
{
/* Clear the dummy text we set before, if any. */
ITfRange *pCompositionRange;
if (_pComposition->GetRange(&pCompositionRange) == S_OK)
pCompositionRange->SetText(ec, 0, L"", 0);
_pComposition->EndComposition(ec);
_pTextService->OnCompositionTerminated(ec, _pComposition);
return S_OK;
}
示例2: _RemoveDummyCompositionForComposing
HRESULT CSampleIME::_RemoveDummyCompositionForComposing(TfEditCookie ec, _In_ ITfComposition *pComposition)
{
HRESULT hr = S_OK;
ITfRange* pRange = nullptr;
if (pComposition)
{
hr = pComposition->GetRange(&pRange);
if (SUCCEEDED(hr))
{
pRange->SetText(ec, 0, nullptr, 0);
pRange->Release();
}
}
return hr;
}
示例3: ToggleCase
void ToggleCase(TfEditCookie ec, ITfRange *pRange, BOOL fIgnoreRangeEnd)
{
ITfRange *pRangeToggle;
ULONG cch;
ULONG i;
DWORD dwFlags;
WCHAR achText[64];
// backup the current range
if (pRange->Clone(&pRangeToggle) != S_OK)
return;
dwFlags = TF_TF_MOVESTART | (fIgnoreRangeEnd ? TF_TF_IGNOREEND : 0);
while (TRUE)
{
// grab the next block of chars
if (pRange->GetText(ec, dwFlags, achText, ARRAYSIZE(achText), &cch) != S_OK)
break;
// out of text?
if (cch == 0)
break;
// toggle the case
for (i=0; i<cch; i++)
{
achText[i] = ToggleChar(achText[i]);
}
// shift pRangeToggle so it covers just the text we read
if (pRangeToggle->ShiftEndToRange(ec, pRange, TF_ANCHOR_START) != S_OK)
break;
// replace the text
pRangeToggle->SetText(ec, 0, achText, cch);
// prepare for next iteration
pRangeToggle->Collapse(ec, TF_ANCHOR_END);
}
pRangeToggle->Release();
}
示例4: _SetText
HRESULT CTextService::_SetText(TfEditCookie ec, ITfContext *pContext, const std::wstring &text, LONG cchCursor, LONG cchOkuri, BOOL fixed)
{
TF_SELECTION tfSelection;
ULONG cFetched = 0;
LONG cch, cchRes;
if(pContext == NULL && _pCandidateList != NULL) //辞書登録用
{
_pCandidateList->_SetText(text, fixed, FALSE, FALSE);
return S_OK;
}
if(!_IsComposing())
{
if(!_StartComposition(pContext))
{
return S_FALSE;
}
}
if(pContext->GetSelection(ec, TF_DEFAULT_SELECTION, 1, &tfSelection, &cFetched) != S_OK)
{
return S_FALSE;
}
if(cFetched != 1)
{
SafeRelease(&tfSelection.range);
return S_FALSE;
}
ITfRange *pRange;
if(_IsComposing() && _pComposition->GetRange(&pRange) == S_OK)
{
if(_IsRangeCovered(ec, tfSelection.range, pRange))
{
pRange->SetText(ec, 0, text.c_str(), (LONG)text.size());
// shift from end to start.
// shift over mathematical operators (U+2200-U+22FF) is rejected by OneNote.
if(cchCursor == 0)
{
cchRes = (LONG)cursoridx - (LONG)kana.size();
if((complement && okuriidx != 0) ||
(!cx_showmodemark && okuriidx != 0 && cursoridx <= okuriidx && cursoridx < kana.size()))
{
cchRes += 1;
}
}
else
{
cchRes = cchCursor - (LONG)text.size();
if(cchRes > 0)
{
cchRes = 0;
}
else if(cchRes < -(LONG)text.size())
{
cchRes = -(LONG)text.size();
}
}
tfSelection.range->ShiftEndToRange(ec, pRange, TF_ANCHOR_END);
tfSelection.range->ShiftStartToRange(ec, pRange, TF_ANCHOR_END);
tfSelection.range->ShiftStart(ec, cchRes, &cch, NULL);
//decide cursor position
tfSelection.range->Collapse(ec, TF_ANCHOR_START);
pContext->SetSelection(ec, 1, &tfSelection);
//composition attribute
if(!fixed)
{
ITfRange *pRangeClone;
if(pRange->Clone(&pRangeClone) == S_OK)
{
pRangeClone->ShiftEndToRange(ec, pRange, TF_ANCHOR_END);
pRangeClone->ShiftStartToRange(ec, pRange, TF_ANCHOR_START);
if(cchCursor == 0 || !showentry)
{
if(inputkey)
{
_SetCompositionDisplayAttributes(ec, pContext, pRangeClone, _gaDisplayAttributeInputMark);
if(cx_showmodemark)
{
pRangeClone->ShiftStart(ec, 1, &cch, NULL);
}
}
if(!display_attribute_series[1] || !inputkey)
{
_SetCompositionDisplayAttributes(ec, pContext, pRangeClone, _gaDisplayAttributeInputText);
}
if(cchOkuri != 0)
{
pRangeClone->ShiftStartToRange(ec, pRange, TF_ANCHOR_START);
pRangeClone->ShiftStart(ec, cchOkuri, &cch, NULL);
if(!display_attribute_series[2])
{
//.........这里部分代码省略.........