예제 #1
0
BOOL CTextService::_InitLanguageBar()
{
    ITfLangBarItemMgr *pLangBarItemMgr;
    BOOL fRet = FALSE;
    BOOL fRetI = FALSE;

    _pLangBarItem = nullptr;
    _pLangBarItemI = nullptr;

    if(_pThreadMgr->QueryInterface(IID_PPV_ARGS(&pLangBarItemMgr)) == S_OK)
    {
        try
        {
            _pLangBarItem = new CLangBarItemButton(this, c_guidLangBarItemButton);
            if(pLangBarItemMgr->AddItem(_pLangBarItem) == S_OK)
            {
                fRet = TRUE;
            }
            else
            {
                SafeRelease(&_pLangBarItem);
            }
        }
        catch(...)
        {
        }

        if(IsWindowsVersion62OrLater())
        {
            try
            {
                _pLangBarItemI = new CLangBarItemButton(this, GUID_LBI_INPUTMODE);
                if(pLangBarItemMgr->AddItem(_pLangBarItemI) == S_OK)
                {
                    fRetI = TRUE;
                }
                else
                {
                    SafeRelease(&_pLangBarItemI);
                }
            }
            catch(...)
            {
            }
        }
        else
        {
            fRetI = TRUE;
        }

        SafeRelease(&pLangBarItemMgr);
    }

    return (fRet && fRetI);
}
예제 #2
0
void TextService::addButton(LangBarButton* button) {
	if(button) {
		langBarButtons_.push_back(button);
		button->AddRef();
		if(isActivated()) {
			ITfLangBarItemMgr* langBarItemMgr;
			if(threadMgr_->QueryInterface(IID_ITfLangBarItemMgr, (void**)&langBarItemMgr) == S_OK) {
				langBarItemMgr->AddItem(button);
				langBarItemMgr->Release();
			}
		}
	}
}
예제 #3
0
HRESULT CLangBarItemButton::_AddItem(_In_ ITfThreadMgr *pThreadMgr)
{
    HRESULT hr = S_OK;
    ITfLangBarItemMgr* pLangBarItemMgr = nullptr;

    if (_isAddedToLanguageBar || pThreadMgr == nullptr)
    {
        return S_OK;
    }

    hr = pThreadMgr->QueryInterface(IID_ITfLangBarItemMgr, (void **)&pLangBarItemMgr);
    if (SUCCEEDED(hr) && pLangBarItemMgr)
    {
        hr = pLangBarItemMgr->AddItem(this);
        if (SUCCEEDED(hr))
        {
            _isAddedToLanguageBar = TRUE;
        }
        pLangBarItemMgr->Release();
    }

    return hr;
}