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);
        }
    }
}
Exemplo n.º 2
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;
}
Exemplo n.º 3
0
void CTextService::_UninitLanguageBar()
{
    ITfLangBarItemMgr *pLangBarItemMgr;

    if(_pLangBarItem != nullptr)
    {
        if(_pThreadMgr->QueryInterface(IID_PPV_ARGS(&pLangBarItemMgr)) == S_OK)
        {
            pLangBarItemMgr->RemoveItem(_pLangBarItem);
            SafeRelease(&pLangBarItemMgr);
        }
    }
    SafeRelease(&_pLangBarItem);

    if(_pLangBarItemI != nullptr)
    {
        if(_pThreadMgr->QueryInterface(IID_PPV_ARGS(&pLangBarItemMgr)) == S_OK)
        {
            pLangBarItemMgr->RemoveItem(_pLangBarItemI);
            SafeRelease(&pLangBarItemMgr);
        }
    }
    SafeRelease(&_pLangBarItemI);
}