本文整理汇总了C++中ITfDocumentMgr::GetTop方法的典型用法代码示例。如果您正苦于以下问题:C++ ITfDocumentMgr::GetTop方法的具体用法?C++ ITfDocumentMgr::GetTop怎么用?C++ ITfDocumentMgr::GetTop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ITfDocumentMgr
的用法示例。
在下文中一共展示了ITfDocumentMgr::GetTop方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _Menu_OnComposition
/* static */
void CMarkTextService::_Menu_OnComposition(CMarkTextService *_this)
{
ITfDocumentMgr *pFocusDoc;
ITfContext *pContext;
CCompositionEditSession *pCompositionEditSession;
HRESULT hr;
// get the focus document
if (_this->_pThreadMgr->GetFocus(&pFocusDoc) != S_OK)
return;
// we want the topmost context, since the main doc context could be
// superceded by a modal tip context
if (pFocusDoc->GetTop(&pContext) != S_OK)
{
pContext = NULL;
goto Exit;
}
if (pCompositionEditSession = new CCompositionEditSession(pContext, _this))
{
// we need a document write lock
// the CCompositionEditSession will do all the work when the
// CCompositionEditSession::DoEditSession method is called by the context
pContext->RequestEditSession(_this->_tfClientId, pCompositionEditSession, TF_ES_READWRITE | TF_ES_ASYNCDONTCARE, &hr);
pCompositionEditSession->Release();
}
Exit:
SafeRelease(pContext);
pFocusDoc->Release();
}
示例2: InsertHello
void CTextService::InsertHello()
{
ITfDocumentMgr *pDocMgrFocus;
ITfContext *pContext;
CInsertHelloEditSession *pInsertHelloEditSession;
HRESULT hr;
// get the focus document
if (_pThreadMgr->GetFocus(&pDocMgrFocus) != S_OK)
return;
// we want the topmost context, since the main doc context could be
// superceded by a modal tip context
if (pDocMgrFocus->GetTop(&pContext) != S_OK)
{
pContext = NULL;
goto Exit;
}
if (pInsertHelloEditSession = new CInsertHelloEditSession(pContext))
{
// we need a document write lock to insert text
// the CInsertHelloEditSession will do all the work when the
// CInsertHelloEditSession::DoEditSession method is called by the context
pContext->RequestEditSession(_tfClientId, pInsertHelloEditSession, TF_ES_READWRITE | TF_ES_ASYNCDONTCARE, &hr);
pInsertHelloEditSession->Release();
}
Exit:
if (pContext)
pContext->Release();
pDocMgrFocus->Release();
}
示例3: currentContext
ITfContext* TextService::currentContext() {
ITfContext* context = NULL;
ITfDocumentMgr *docMgr;
if(threadMgr_->GetFocus(&docMgr) == S_OK) {
docMgr->GetTop(&context);
docMgr->Release();
}
return context;
}
示例4: _CandidateChangeNotification
HRESULT CCandidateListUIPresenter::_CandidateChangeNotification(_In_ enum CANDWND_ACTION action)
{
HRESULT hr = E_FAIL;
TfClientId tfClientId = _pTextService->_GetClientId();
ITfThreadMgr* pThreadMgr = nullptr;
ITfDocumentMgr* pDocumentMgr = nullptr;
ITfContext* pContext = nullptr;
_KEYSTROKE_STATE KeyState;
KeyState.Category = _Category;
KeyState.Function = FUNCTION_FINALIZE_CANDIDATELIST;
if (CAND_ITEM_SELECT != action)
{
goto Exit;
}
pThreadMgr = _pTextService->_GetThreadMgr();
if (nullptr == pThreadMgr)
{
goto Exit;
}
hr = pThreadMgr->GetFocus(&pDocumentMgr);
if (FAILED(hr))
{
goto Exit;
}
hr = pDocumentMgr->GetTop(&pContext);
if (FAILED(hr))
{
pDocumentMgr->Release();
goto Exit;
}
CKeyHandlerEditSession *pEditSession = new (std::nothrow) CKeyHandlerEditSession(_pTextService, pContext, 0, 0, KeyState);
if (nullptr != pEditSession)
{
HRESULT hrSession = S_OK;
hr = pContext->RequestEditSession(tfClientId, pEditSession, TF_ES_SYNC | TF_ES_READWRITE, &hrSession);
if (hrSession == TF_E_SYNCHRONOUS || hrSession == TS_E_READONLY)
{
hr = pContext->RequestEditSession(tfClientId, pEditSession, TF_ES_ASYNC | TF_ES_READWRITE, &hrSession);
}
pEditSession->Release();
}
pContext->Release();
pDocumentMgr->Release();
Exit:
return hr;
}
示例5: _AttachStaticProperty
void CTextService::_AttachStaticProperty(WCHAR *psz)
{
ITfDocumentMgr *pDocMgrFocus;
ITfContext *pContext;
if ((_pThreadMgr->GetFocus(&pDocMgrFocus) == S_OK) &&
(pDocMgrFocus != NULL))
{
if (pDocMgrFocus->GetTop(&pContext) == S_OK)
{
CStaticPropertyEditSession *pEditSession;
if (pEditSession = new CStaticPropertyEditSession(this, pContext, psz))
{
HRESULT hr;
pContext->RequestEditSession(_tfClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READWRITE, &hr);
pEditSession->Release();
}
pContext->Release();
}
pDocMgrFocus->Release();
}
return;
}
示例6: _IsKeyboardDisabled
BOOL CTextService::_IsKeyboardDisabled()
{
ITfCompartmentMgr *pCompMgr = NULL;
ITfDocumentMgr *pDocMgrFocus = NULL;
ITfContext *pContext = NULL;
BOOL fDisabled = FALSE;
if ((_pThreadMgr->GetFocus(&pDocMgrFocus) != S_OK) ||
(pDocMgrFocus == NULL))
{
// if there is no focus document manager object, the keyboard
// is disabled.
fDisabled = TRUE;
goto Exit;
}
if ((pDocMgrFocus->GetTop(&pContext) != S_OK) ||
(pContext == NULL))
{
// if there is no context object, the keyboard is disabled.
fDisabled = TRUE;
goto Exit;
}
if (pContext->QueryInterface(IID_ITfCompartmentMgr, (void **)&pCompMgr) == S_OK)
{
ITfCompartment *pCompartmentDisabled;
ITfCompartment *pCompartmentEmptyContext;
// Check GUID_COMPARTMENT_KEYBOARD_DISABLED.
if (pCompMgr->GetCompartment(GUID_COMPARTMENT_KEYBOARD_DISABLED, &pCompartmentDisabled) == S_OK)
{
VARIANT var;
if (S_OK == pCompartmentDisabled->GetValue(&var))
{
if (var.vt == VT_I4) // Even VT_EMPTY, GetValue() can succeed
{
fDisabled = (BOOL)var.lVal;
}
}
pCompartmentDisabled->Release();
}
// Check GUID_COMPARTMENT_EMPTYCONTEXT.
if (pCompMgr->GetCompartment(GUID_COMPARTMENT_EMPTYCONTEXT, &pCompartmentEmptyContext) == S_OK)
{
VARIANT var;
if (S_OK == pCompartmentEmptyContext->GetValue(&var))
{
if (var.vt == VT_I4) // Even VT_EMPTY, GetValue() can succeed
{
fDisabled = (BOOL)var.lVal;
}
}
pCompartmentEmptyContext->Release();
}
pCompMgr->Release();
}
Exit:
if (pContext)
pContext->Release();
if (pDocMgrFocus)
pDocMgrFocus->Release();
return fDisabled;
}