Example #1
0
STDAPI CCandidateList::OnLayoutChange(ITfContext *pContext, TfLayoutCode lcode, ITfContextView *pContextView){
    if (pContext != _pContextDocument)
        return S_OK;

    switch (lcode){
    case TF_LC_CHANGE:
        if (_pCandidateWindow != NULL)
        {
            CGetTextExtentEditSession *pEditSession;

            if ((pEditSession = new CGetTextExtentEditSession(_pTextService, pContext, pContextView, _pRangeComposition, _pCandidateWindow)) != NULL)
            {
                HRESULT hr;
                // a lock is required
                // nb: this method is one of the few places where it is legal to use
                // the TF_ES_SYNC flag
                pContext->RequestEditSession(_pTextService->_GetClientId(), pEditSession, TF_ES_SYNC | TF_ES_READ, &hr);

                pEditSession->Release();
             }
        }
        break;

    case TF_LC_DESTROY:
        _EndCandidateList();
        break;
    }

    return S_OK;
}
Example #2
0
/* Composition Window Handling */
BOOL WeaselTSF::_UpdateCompositionWindow(ITfContext *pContext)
{
	ITfContextView *pContextView = NULL;
	if (pContext->GetActiveView(&pContextView) != S_OK)
		return FALSE;
	CGetTextExtentEditSession *pEditSession;
	if ((pEditSession = new CGetTextExtentEditSession(this, pContext, pContextView, _pComposition)) != NULL)
	{
		HRESULT hr;
		pContext->RequestEditSession(_tfClientId, pEditSession, TF_ES_ASYNCDONTCARE | TF_ES_READ, &hr);
		pEditSession->Release();
		pContextView->Release();
		return TRUE;
	}
	pContextView->Release();
	return FALSE;
}