I try to implement custom effect on direct2d, my Effects Register method works fine, but on createeffect method I have returned value "HRESULT_FROM_WIN32(ERROR_NOT_FOUND): Element not found". Here is my Register, and pointer creating methods.And
my project is a dll.
HRESULT SplashEffect::Register(_In_ ID2D1Factory1* pFactory)
{
// The inspectable metadata of an effect is defined in XML. This can be passed in from an external source
// as well, however for simplicity we just inline the XML.
PCWSTR pszXml =
XML(
<?xml version='1.0'?>
<Effect>
<!-- System Properties -->
<Property name='DisplayName' type='string' value='Ripple'/>
<Property name='Author' type='string' value='Microsoft Corporation'/>
<Property name='Category' type='string' value='Stylize'/>
<Property name='Description' type='string' value='Adds a ripple effect that can be animated'/>
<Inputs>
<Input name='Source'/>
</Inputs>
</Effect>
);
return pFactory->RegisterEffectFromString(
GUID_COLOR_SPLASH_EFFECT,
pszXml,
nullptr,
0,
CreateEffectImpl
);
}
HRESULT __stdcall SplashEffect::CreateEffectImpl(_Outptr_ IUnknown** ppEffectImpl)
{
// Since the object's refcount is initialized to 1, we don't need to AddRef here.
*ppEffectImpl = static_cast<ID2D1EffectImpl*>(new (std::nothrow) SplashEffect());
if (*ppEffectImpl == nullptr)
{
return E_OUTOFMEMORY;
}
else
{
return S_OK;
}
}