当前位置: 首页>>代码示例>>C++>>正文


C++ ComPtr::AddItem方法代码示例

本文整理汇总了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;
}
开发者ID:Java2ByteCode,项目名称:PIME,代码行数:81,代码来源:TextService.cpp


注:本文中的ComPtr::AddItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。