本文整理汇总了C++中ITfRange::ShiftEnd方法的典型用法代码示例。如果您正苦于以下问题:C++ ITfRange::ShiftEnd方法的具体用法?C++ ITfRange::ShiftEnd怎么用?C++ ITfRange::ShiftEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITfRange
的用法示例。
在下文中一共展示了ITfRange::ShiftEnd方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoEditSession
STDAPI CInlinePreeditEditSession::DoEditSession(TfEditCookie ec)
{
std::wstring preedit = _context->preedit.str;
ITfRange *pRangeComposition = NULL;
if ((_pComposition->GetRange(&pRangeComposition)) != S_OK)
goto Exit;
if ((pRangeComposition->SetText(ec, 0, preedit.c_str(), preedit.length())) != S_OK)
goto Exit;
int sel_start = 0, sel_end = 0; /* TODO: Check the availability and correctness of these values */
for (size_t i = 0; i < _context->preedit.attributes.size(); i++)
if (_context->preedit.attributes.at(i).type == weasel::HIGHLIGHTED)
{
sel_start = _context->preedit.attributes.at(i).range.start;
sel_end = _context->preedit.attributes.at(i).range.end;
break;
}
/* Set caret */
LONG cch;
TF_SELECTION tfSelection;
pRangeComposition->Collapse(ec, TF_ANCHOR_START);
pRangeComposition->ShiftEnd(ec, sel_end, &cch, NULL);
pRangeComposition->ShiftStart(ec, sel_start, &cch, NULL);
tfSelection.range = pRangeComposition;
tfSelection.style.ase = TF_AE_NONE;
tfSelection.style.fInterimChar = FALSE;
_pContext->SetSelection(ec, 1, &tfSelection);
Exit:
if (pRangeComposition != NULL)
pRangeComposition->Release();
return S_OK;
}
示例2: _DumpExtent
//.........这里部分代码省略.........
AddStringToStream(_pMemStream, L"Start Pos\r\n");
if (SUCCEEDED(pContext->GetStart(ec, &pRange)))
{
if (SUCCEEDED(pView->GetTextExt(ec, pRange, &rc, &fClipped)))
{
StringCchPrintf(sz, ARRAYSIZE(sz), L" (%d, %d, %d, %d) - (%d, %d) %s\r\n", rc.left, rc.top, rc.right, rc.bottom, rc.right - rc.left, rc.bottom - rc.top, fClipped ? L"Clipped" : L"");
AddStringToStream(_pMemStream, sz);
_rcStartPos = rc;
}
pRange->Release();
}
AddStringToStream(_pMemStream, L"End Pos\r\n");
if (SUCCEEDED(pContext->GetEnd(ec, &pRange)))
{
if (SUCCEEDED(pView->GetTextExt(ec, pRange, &rc, &fClipped)))
{
StringCchPrintf(sz, ARRAYSIZE(sz), L" (%d, %d, %d, %d) - (%d, %d) %s\r\n", rc.left, rc.top, rc.right, rc.bottom, rc.right - rc.left, rc.bottom - rc.top, fClipped ? L"Clipped" : L"");
AddStringToStream(_pMemStream, sz);
_rcEndPos = rc;
}
pRange->Release();
}
AddStringToStream(_pMemStream, L"Selection Pos\r\n");
ULONG cFetched;
if (SUCCEEDED(pContext->GetSelection(ec, 0, 1, &sel, &cFetched)))
{
if (sel.range)
{
if (SUCCEEDED(pView->GetTextExt(ec, sel.range, &rc, &fClipped)))
{
StringCchPrintf(sz, ARRAYSIZE(sz), L" (%d, %d, %d, %d) - (%d, %d) %s\r\n", rc.left, rc.top, rc.right, rc.bottom, rc.right - rc.left, rc.bottom - rc.top, fClipped ? L"Clipped" : L"");
AddStringToStream(_pMemStream, sz);
_rcSelection = rc;
}
AddStringToStream(_pMemStream, L" ");
_DumpRange(ec, sel.range);
AddStringToStream(_pMemStream, L"\r\n");
sel.range->Release();
}
}
AddStringToStream(_pMemStream, L"Char Pos\r\n");
if (SUCCEEDED(pContext->GetStart(ec, &pRange)))
{
LONG cch;
memset(&_rcRanges[0] , 0, sizeof(RECT) * ARRAYSIZE(_rcRanges));
if (SUCCEEDED(pRange->ShiftEnd(ec, 1, &cch, NULL)) && cch)
{
for (int i = 0; i < ARRAYSIZE(_rcRanges); i++)
{
if (SUCCEEDED(pView->GetTextExt(ec, pRange, &rc, &fClipped)))
{
StringCchPrintf(sz, ARRAYSIZE(sz), L" (%d, %d, %d, %d) - (%d, %d) %s", rc.left, rc.top, rc.right, rc.bottom, rc.right - rc.left, rc.bottom - rc.top, fClipped ? L"Clipped" : L"");
AddStringToStream(_pMemStream, sz);
AddStringToStream(_pMemStream, L" ");
ITfRange *pRangeTmp;
if (SUCCEEDED(pRange->Clone(&pRangeTmp)))
{
_DumpRange(ec, pRangeTmp);
pRangeTmp->Release();
}
AddStringToStream(_pMemStream, L"\r\n");
OffsetRect(&rc, 0 - _rcView.left, 0 - _rcView.top);
_rcRanges[i] = rc;
}
if (FAILED(pRange->ShiftEnd(ec, 1, &cch, NULL)) || !cch)
break;
if (FAILED(pRange->ShiftStart(ec, 1, &cch, NULL)) || !cch)
break;
}
}
pRange->Release();
}
pView->Release();
}
_EnsurePopupWindow();
if (IsShownExtentVisualWindows())
_UpdateExtentVisualWindows();
if (IsShownRangeExtentViewer())
_UpdateRangeExtentViewer();
return;
}