// idl
[propget, id(3), helpstring("property myenum")] HRESULT myenum1([out, retval] long* pVal);
[propput, id(3), helpstring("property myenum")] HRESULT myenum1([in] long newVal);
// COM Wrapper header
STDMETHOD(GetPredefinedStrings)(
/* [in] */ DISPID dispID,
/* [out] */ CALPOLESTR *pCaStringsOut,
/* [out] */ CADWORD *pCaCookiesOut);
STDMETHOD(GetPredefinedValue)(
/* [in] */ DISPID dispID,
/* [out] */ DWORD dwCookie,
/* [out] */ VARIANT *pVarOut);
// COM Wrapper cpp
//- IAcPiPropertyDisplay
STDMETHODIMP CMyObject::GetCustomPropertyCtrl (VARIANT Id, LCID lcid, BSTR *pProgId) {
if ( pProgId == NULL )
return (E_FAIL) ;
if ( V_I4(&Id) == 3 ) {
LPOLESTR progId;
ProgIDFromCLSID (CLSID_AcPePropertyEditorEnum, &progId);
*pProgId =::SysAllocString (progId);
return (S_OK) ;
}
return (E_NOTIMPL) ;
}
STDMETHODIMP CMyObject::GetPredefinedStrings(DISPID dispID, CALPOLESTR *pCaStringsOut, CADWORD *pCaCookiesOut)
{
USES_CONVERSION;
if( (dispID == 0x3))
{
pCaStringsOut->pElems = (LPOLESTR *)::CoTaskMemAlloc(sizeof(LPOLESTR) * 2);
pCaCookiesOut->pElems = (DWORD *)::CoTaskMemAlloc(sizeof(DWORD) * 2);
pCaStringsOut->pElems[0] = ::SysAllocString(L"First");
pCaCookiesOut->pElems[0] = 1;
pCaStringsOut->pElems[1] = ::SysAllocString(L"Second");
pCaCookiesOut->pElems[1] = 2;
pCaStringsOut->cElems = 2;
pCaCookiesOut->cElems = 2;
return S_OK;
}
return IOPMPropertyExtensionImpl<CMyObject>::GetPredefinedStrings(dispID,pCaStringsOut,pCaCookiesOut);
}
STDMETHODIMP CMyObject::GetPredefinedValue(DISPID dispID, DWORD dwCookie, VARIANT *pVarOut)
{
if(dispID == 0x3)
{
if(dwCookie == 1)
{
::VariantCopy(pVarOut, &CComVariant((long)1));
}
else if(dwCookie == 2)
{
::VariantCopy(pVarOut, &CComVariant((long)2));
}
}
else
return IOPMPropertyExtensionImpl<CMyObject>::GetPredefinedValue(dispID, dwCookie, pVarOut);
return S_OK;
}