Ejemplo n.º 1
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();
			}
		}
	}
}
Ejemplo n.º 2
0
void TextService::removeButton(LangBarButton* button) {
	if(button) {
		vector<LangBarButton*>::iterator it;
		it = find(langBarButtons_.begin(), langBarButtons_.end(), button);
		if(it != langBarButtons_.end()) {
			if(isActivated()) {
				ITfLangBarItemMgr* langBarItemMgr;
				if(threadMgr_->QueryInterface(IID_ITfLangBarItemMgr, (void**)&langBarItemMgr) == S_OK) {
					langBarItemMgr->RemoveItem(button);
					langBarItemMgr->Release();
				}
			}
			button->Release();
			langBarButtons_.erase(it);
		}
	}
}
Ejemplo n.º 3
0
HRESULT CLangBarItemButton::_RemoveItem(_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->RemoveItem(this);
        if (SUCCEEDED(hr))
        {
            _isAddedToLanguageBar = FALSE;
        }
        pLangBarItemMgr->Release();
    }

    return hr;
}