本文整理汇总了C++中CComQIPtr::GetFloatProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ CComQIPtr::GetFloatProperty方法的具体用法?C++ CComQIPtr::GetFloatProperty怎么用?C++ CComQIPtr::GetFloatProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComQIPtr
的用法示例。
在下文中一共展示了CComQIPtr::GetFloatProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr;
// Initializes the COM library on the current thread and identifies the
// concurrency model as single-thread apartment (STA).
::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
/////////////////////////////////////////////////////////////////////////
// Create the ATLDllCOMServer.SimpleObject COM object using the
// #import directive and smart pointers.
//
CComQIPtr<ISimpleObject> spSimpleObj;
hr = spSimpleObj.CoCreateInstance(OLESTR(
"ATLDllCOMServer.SimpleObject"));
if (FAILED(hr))
{
_tprintf(_T(
"ISimpleObjectPtr.CoCreateInstance failed w/err 0x%08lx\n"
), hr);
return hr;
}
/////////////////////////////////////////////////////////////////////////
// Use sink object 1 (CATLSimpleSinkObject1) to set up the sink for the
// events of the source COM object.
//
_putts(_T("Create sink object 1"));
// Construct the sink object CATLSimpleSinkObject1 defined in
// ATLSimpleSinkObject.h
CATLSimpleSinkObject1* pSinkObj1 = new CATLSimpleSinkObject1();
// Make sure the COM object corresponding to pUnk implements
// IProvideClassInfo2 or IPersist*. Call this method to extract info
// about source type library if you specified only 2 parameters to
// IDispEventImpl.
hr = AtlGetObjectSourceInterface(spSimpleObj, &pSinkObj1->m_libid,
&pSinkObj1->m_iid, &pSinkObj1->m_wMajorVerNum,
&pSinkObj1->m_wMinorVerNum);
_ASSERTE(SUCCEEDED(hr));
// Connect the sink and source, spSimpleObj is the source COM object
hr = pSinkObj1->DispEventAdvise(spSimpleObj, &pSinkObj1->m_iid);
_ASSERTE(SUCCEEDED(hr));
// Invoke the source COM object
{
// Set FloatProperty which fires the event FloatPropertyChanging
_tprintf(_T("Set FloatProperty = %.2f\n"), 1.1f);
spSimpleObj->PutFloatProperty(1.1f);
float fProp = spSimpleObj->GetFloatProperty();
_tprintf(_T("Get FloatProperty = %.2f\n"), fProp);
}
// Disconnect from the source COM object if connected
if (pSinkObj1->m_dwEventCookie != 0xFEFEFEFE)
pSinkObj1->DispEventUnadvise(spSimpleObj, &pSinkObj1->m_iid);
// Destroy the sink object
delete pSinkObj1;
/////////////////////////////////////////////////////////////////////////
// Use sink object 2 (CATLSimpleSinkObject2) to set up the sink for the
// events of the source COM object.
//
_putts(_T("Create sink object 2"));
// Construct the sink object CATLSimpleSinkObject2 defined in
// ATLSimpleSinkObject.h
CATLSimpleSinkObject2* pSinkObj2 = new CATLSimpleSinkObject2();
// Connect the sink and source, m_spSrcObj is the source COM object
hr = pSinkObj2->DispEventAdvise(spSimpleObj);
_ASSERTE(SUCCEEDED(hr));
// Invoke the source COM object
{
// Set FloatProperty which fires the event FloatPropertyChanging
_tprintf(_T("Set FloatProperty = %.2f\n"), 1.2f);
spSimpleObj->PutFloatProperty(1.2f);
float fProp = spSimpleObj->GetFloatProperty();
_tprintf(_T("Get FloatProperty = %.2f\n"), fProp);
}
// Disconnect from source if connected
if (pSinkObj2->m_dwEventCookie != 0xFEFEFEFE)
pSinkObj2->DispEventUnadvise(spSimpleObj);
//.........这里部分代码省略.........