Esempio n. 1
0
BOOL CTextService::_InitTextEditSink(ITfDocumentMgr *pDocumentMgr)
{
	BOOL fRet = FALSE;

	if(_pTextEditSinkContext != nullptr && _dwTextEditSinkCookie != TF_INVALID_COOKIE)
	{
		ITfSource *pSource = nullptr;
		if(SUCCEEDED(_pTextEditSinkContext->QueryInterface(IID_PPV_ARGS(&pSource))) && (pSource != nullptr))
		{
			pSource->UnadviseSink(_dwTextEditSinkCookie);
			SafeRelease(&pSource);
		}

		SafeRelease(&_pTextEditSinkContext);
		_dwTextEditSinkCookie = TF_INVALID_COOKIE;
	}

	if(pDocumentMgr == nullptr)
	{
		return TRUE;
	}

	if(FAILED(pDocumentMgr->GetTop(&_pTextEditSinkContext)))
	{
		return FALSE;
	}

	if(_pTextEditSinkContext == nullptr)
	{
		return TRUE;
	}

	{
		ITfSource *pSource = nullptr;
		if(SUCCEEDED(_pTextEditSinkContext->QueryInterface(IID_PPV_ARGS(&pSource))) && (pSource != nullptr))
		{
			if(SUCCEEDED(pSource->AdviseSink(IID_IUNK_ARGS((ITfTextEditSink *)this), &_dwTextEditSinkCookie)))
			{
				fRet = TRUE;
			}
			else
			{
				_dwTextEditSinkCookie = TF_INVALID_COOKIE;
			}
			SafeRelease(&pSource);
		}
	}

	if(fRet == FALSE)
	{
		SafeRelease(&_pTextEditSinkContext);
	}

	return fRet;
}
Esempio n. 2
0
HRESULT CInputModeWindow::_AdviseTextLayoutSink()
{
	HRESULT hr = E_FAIL;

	ITfSource *pSource;
	if(_pContext->QueryInterface(IID_PPV_ARGS(&pSource)) == S_OK)
	{
		hr = pSource->AdviseSink(IID_IUNK_ARGS((ITfTextLayoutSink *)this), &_dwCookieTextLayoutSink);
		SafeRelease(&pSource);
	}

	return hr;
}
HRESULT CCandidateList::_AdviseContextKeyEventSink()
{
	HRESULT hr = E_FAIL;

	ITfSource *pSource;
	if(_pContextCandidateWindow->QueryInterface(IID_PPV_ARGS(&pSource)) == S_OK)
	{
		hr = pSource->AdviseSink(IID_IUNK_ARGS((ITfContextKeyEventSink *)this), &_dwCookieContextKeyEventSink);
		SafeRelease(&pSource);
	}

	return hr;
}
Esempio n. 4
0
BOOL CTextService::_InitThreadMgrEventSink()
{
	BOOL fRet = FALSE;

	ITfSource *pSource = nullptr;
	if(SUCCEEDED(_pThreadMgr->QueryInterface(IID_PPV_ARGS(&pSource))) && (pSource != nullptr))
	{
		if(SUCCEEDED(pSource->AdviseSink(IID_IUNK_ARGS((ITfThreadMgrEventSink *)this), &_dwThreadMgrEventSinkCookie)))
		{
			fRet = TRUE;
		}
		else
		{
			_dwThreadMgrEventSinkCookie = TF_INVALID_COOKIE;
		}
		SafeRelease(&pSource);
	}

	return fRet;
}