I'm having trouble implementing IObjectSafety. IE keeps telling me that my controls isn't safe. Why?


I'm having trouble implementing IObjectSafety. IE keeps telling me that my controls isn't safe. Why?

Below is some code that I got from the ATL list (Thanks to [email protected]). It implements IObjectSafety. ATL's IObjectSafetyImpl class appears to have a few bugs in it. The code below works great. Add the lines in bold.

class ATL_NO_VTABLE CNoteCtl :
public CComObjectRootEx<CComSingleThreadModel>,
...
// Derive from IObjectSafety
public IObjectSafety
{
...
BEGIN_COM_MAP(CNoteCtl)
COM_INTERFACE_ENTRY(INoteCtl)
COM_INTERFACE_ENTRY(IDispatch)
...
// Add it to our interface map
COM_INTERFACE_ENTRY(IObjectSafety)
END_COM_MAP()
...
// IObjectSafety implementation
STDMETHODIMP GetInterfaceSafetyOptions( REFIID riid, DWORD
*pdwSupportedOptions, DWORD *pdwEnabledOptions )
{
ATLTRACE(_T("CNoteCtl::GetInterfaceSafetyOptions()\n"));
*pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_CALLER |
INTERFACESAFE_FOR_UNTRUSTED_DATA;
*pdwEnabledOptions = *pdwSupportedOptions;
return S_OK;
STDMETHODIMP SetInterfaceSafetyOptions(REFIID riid, DWORD dwOptionSetMask,
DWORD dwEnabledOptions)
{
ATLTRACE(_T("CNoteCtl::SetInterfaceSafetyOptions\n"));
return S_OK;
}
...
};

Up Next
    Ebook Download
    View all
    Learn
    View all