I've implemented the property page of my ActiveX control like that:
class ATL_NO_VTABLE StringProperties :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<StringProperties, &CLSID_StringProperties>,
public IPropertyPageImpl<StringProperties>,
public CDialogImpl<StringProperties>
{
public:
DECLARE_REGISTRY_RESOURCEID(IDR_STRINGPROPERTIES)
BEGIN_COM_MAP(StringProperties)
COM_INTERFACE_ENTRY(IPropertyPage)
END_COM_MAP()
// ...
};
This works fine in Visual Basic 6.
Now I want to add IPropertyPage2 support. So I changed the class to
derive from IPropertyPage2Impl:
class ATL_NO_VTABLE StringProperties :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<StringProperties, &CLSID_StringProperties>,
public IPropertyPage2Impl<StringProperties>,
public CDialogImpl<StringProperties>
{
public:
DECLARE_REGISTRY_RESOURCEID(IDR_STRINGPROPERTIES)
BEGIN_COM_MAP(StringProperties)
COM_INTERFACE_ENTRY(IPropertyPage)
COM_INTERFACE_ENTRY2(IPropertyPage2, IPropertyPage)
END_COM_MAP()
// ...
};
This compiles, but if I click the "..." next to the property in VB6's
property grid, I get an access violation in ~CComObject. I think the COM
object's ref-counting is broken, but I don't know what's missing.
I don't get this access violation if I open the property pages through
the (Property Pages) entry in the property grid.
What am I doing wrong? I use Visual C++ 2008 SP1 with ATL 9.0 and WTL 8.1.
Regards
Timo
--
www.TimoSoft-Software.de - Unicode controls for VB6
"Those who sacrifice freedom for safety deserve neither."
"Demokratie ist per Definition unsicher. Ihr Schutz entsteht aus der
Überzeugung, dass die demokratischen Kräfte überwiegen und sich – auf
demokratischem Wege – durchsetzen."
> This compiles, but if I click the "..." next to the property in VB6's
> property grid, I get an access violation in ~CComObject. I think the COM
> object's ref-counting is broken, but I don't know what's missing.
> I don't get this access violation if I open the property pages through
> the (Property Pages) entry in the property grid.
>
> What am I doing wrong? I use VC2008 SP1 with ATL 9.0 and WTL 8.1.
I have only found that VC2008's "virtual ~IPropertyPageImpl()" doesn't
correspond to VC6's "~IPropertyPageImpl()". But I'm not sure that is a
problem. It's should be tested.
I've removed the "virtual" keyword, but it doesn't make a difference.
The crash occurs after leaving IPropertyPageImpl::Show. The call comes
directly from the VB6 IDE.