本文整理汇总了C++中ComPtr::AddItem方法的典型用法代码示例。如果您正苦于以下问题:C++ ComPtr::AddItem方法的具体用法?C++ ComPtr::AddItem怎么用?C++ ComPtr::AddItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ComPtr
的用法示例。
在下文中一共展示了ComPtr::AddItem方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Activate
// ITfTextInputProcessor
STDMETHODIMP TextService::Activate(ITfThreadMgr *pThreadMgr, TfClientId tfClientId) {
// store tsf manager & client id
threadMgr_ = pThreadMgr;
clientId_ = tfClientId;
activateFlags_ = 0;
ComQIPtr<ITfThreadMgrEx> threadMgrEx = threadMgr_;
if(threadMgrEx) {
threadMgrEx->GetActiveFlags(&activateFlags_);
}
// advice event sinks (set up event listeners)
// ITfThreadMgrEventSink, ITfActiveLanguageProfileNotifySink
ComQIPtr<ITfSource> source = threadMgr_;
if(source) {
source->AdviseSink(IID_ITfThreadMgrEventSink, (ITfThreadMgrEventSink *)this, &threadMgrEventSinkCookie_);
source->AdviseSink(IID_ITfActiveLanguageProfileNotifySink, (ITfActiveLanguageProfileNotifySink *)this, &activateLanguageProfileNotifySinkCookie_);
}
// ITfTextEditSink,
// ITfKeyEventSink
ComQIPtr<ITfKeystrokeMgr> keystrokeMgr = threadMgr_;
if(keystrokeMgr)
keystrokeMgr->AdviseKeyEventSink(clientId_, (ITfKeyEventSink*)this, TRUE);
// register preserved keys
if(!preservedKeys_.empty()) {
vector<PreservedKey>::iterator it;
for(it = preservedKeys_.begin(); it != preservedKeys_.end(); ++it) {
PreservedKey& preservedKey = *it;
keystrokeMgr->PreserveKey(clientId_, preservedKey.guid, &preservedKey, NULL, 0);
}
}
// ITfCompositionSink
// ITfCompartmentEventSink
// get current keyboard state
if(!compartmentMonitors_.empty()) {
vector<CompartmentMonitor>::iterator it;
for(it = compartmentMonitors_.begin(); it != compartmentMonitors_.end(); ++it) {
ComQIPtr<ITfSource> compartmentSource;
if(it->isGlobal) // global compartment
compartmentSource = globalCompartment(it->guid);
else // thread specific compartment
compartmentSource = threadCompartment(it->guid);
compartmentSource->AdviseSink(IID_ITfCompartmentEventSink, (ITfCompartmentEventSink*)this, &it->cookie);
}
}
isKeyboardOpened_ = threadCompartmentValue(GUID_COMPARTMENT_KEYBOARD_OPENCLOSE);
// FIXME: under Windows 7, it seems that the keyboard is closed every time
// our text service is activated. The value in the compartment is always empty. :-(
// So, we open the keyboard manually here, but I'm not sure if this is the correct behavior.
if(!isKeyboardOpened_)
setKeyboardOpen(true);
// initialize language bar
::CoCreateInstance(CLSID_TF_LangBarMgr, NULL, CLSCTX_INPROC_SERVER,
IID_ITfLangBarMgr, (void**)&langBarMgr_);
if(langBarMgr_) {
langBarMgr_->AdviseEventSink(this, NULL, 0, &langBarSinkCookie_);
}
// Note: language bar has no effects in Win 8 immersive mode
if(!langBarButtons_.empty()) {
ComPtr<ITfLangBarItemMgr> langBarItemMgr;
if(threadMgr_->QueryInterface(IID_ITfLangBarItemMgr, (void**)&langBarItemMgr) == S_OK) {
for(vector<LangBarButton*>::iterator it = langBarButtons_.begin(); it != langBarButtons_.end(); ++it) {
LangBarButton* button = *it;
langBarItemMgr->AddItem(button);
}
}
}
onActivate();
//::MessageBox(0, L"onActivate", 0, 0);
return S_OK;
}