MMC Snapin with OCX Resultview failed to create control 
Author Message
 MMC Snapin with OCX Resultview failed to create control

We're developing an MMC Snapin and would like two OCX Resultviews.  What we
have done is to a develop ActiveX Controls as part of the same library file,
so that the whole dll is self contained and self sufficient.

The first OCX control was developed and instantiates from ActiveX Test
Container as expected.

The second one was inserted exactly the same way the first one was (VC++
Menu Insert/New ATL Object).  With the second one however, we get the error:

'Failed to create control: Unspecified Error'

We have seen the KB support article, Q122792
( http://www.*-*-*.com/ ;EN-GB;q221792), and have
implemented these changed in the control constructor.  However, this is not
the problem, as when we debug the project, execution never reaches the
constructor.

Instead, in the debug window, we can see this:

First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363: Microsoft
C++ Exception.
First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363: Microsoft
C++ Exception.
First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363: Microsoft
C++ Exception.

Some extra debugging we did was to insert the ActiveX Control files into a
new project.  They worked.  Is it something to do with the fact we are
developing an MMC Snapin and already have one control in the dll .idl file?

Appreciate any help given.

Thanks

-- ActiveX Object header file: Reports.h ---

// Reports.h : Declaration of the CReports

#ifndef __REPORTS_H_
#define __REPORTS_H_

#include "resource.h"       // main symbols
#include <atlctl.h>

////////////////////////////////////////////////////////////////////////////
/
// CReports
class ATL_NO_VTABLE CReports :
 public CComObjectRootEx<CComSingleThreadModel>,
 public CStockPropImpl<CReports, IReports, &IID_IReports, &LIBID_WKSNMGMT>,
 public CComCompositeControl<CReports>,
 public IPersistStreamInitImpl<CReports>,
 public IOleControlImpl<CReports>,
 public IOleObjectImpl<CReports>,
 public IOleInPlaceActiveObjectImpl<CReports>,
 public IViewObjectExImpl<CReports>,
 public IOleInPlaceObjectWindowlessImpl<CReports>,
 public ISupportErrorInfo,
 public IPersistStorageImpl<CReports>,
 public ISpecifyPropertyPagesImpl<CReports>,
 public IQuickActivateImpl<CReports>,
 public IDataObjectImpl<CReports>,
 public IProvideClassInfo2Impl<&CLSID_Reports, NULL, &LIBID_WKSNMGMT>,
 public CComCoClass<CReports, &CLSID_Reports>
{
public:
 CReports()
 {
  m_bWindowOnly = TRUE;
  CalcExtent(m_sizeExtent);

  IDispatchImpl<IReports, &IID_IReports, &LIBID_WKSNMGMT, 1,
0>::_tih.m_wMajor = 2;
  IDispatchImpl<IReports, &IID_IReports, &LIBID_WKSNMGMT, 1,
0>::_tih.m_wMinor = 5;

 }

DECLARE_REGISTRY_RESOURCEID(IDR_REPORTS)

DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CReports)
 COM_INTERFACE_ENTRY(IReports)
 COM_INTERFACE_ENTRY(IDispatch)
 COM_INTERFACE_ENTRY(IViewObjectEx)
 COM_INTERFACE_ENTRY(IViewObject2)
 COM_INTERFACE_ENTRY(IViewObject)
 COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
 COM_INTERFACE_ENTRY(IOleInPlaceObject)
 COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
 COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
 COM_INTERFACE_ENTRY(IOleControl)
 COM_INTERFACE_ENTRY(IOleObject)
 COM_INTERFACE_ENTRY(IPersistStreamInit)
 COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
 COM_INTERFACE_ENTRY(ISupportErrorInfo)
 COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
 COM_INTERFACE_ENTRY(IQuickActivate)
 COM_INTERFACE_ENTRY(IPersistStorage)
 COM_INTERFACE_ENTRY(IDataObject)
 COM_INTERFACE_ENTRY(IProvideClassInfo)
 COM_INTERFACE_ENTRY(IProvideClassInfo2)
END_COM_MAP()

BEGIN_PROP_MAP(CReports)
 PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
 PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
 PROP_ENTRY("Enabled", DISPID_ENABLED, CLSID_NULL)
 // Example entries
 // PROP_ENTRY("Property Description", dispid, clsid)
 // PROP_PAGE(CLSID_StockColorPage)
END_PROP_MAP()

BEGIN_MSG_MAP(CReports)
 CHAIN_MSG_MAP(CComCompositeControl<CReports>)
END_MSG_MAP()
// Handler prototypes:
//  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL&
bHandled);
//  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL&
bHandled);
//  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

BEGIN_SINK_MAP(CReports)
 //Make sure the Event Handlers have __stdcall calling convention
END_SINK_MAP()

 STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
 {
  if (dispid == DISPID_AMBIENT_BACKCOLOR)
  {
   SetBackgroundColorFromAmbient();
   FireViewChange();
  }
  return IOleControlImpl<CReports>::OnAmbientPropertyChange(dispid);
 }

// ISupportsErrorInfo
 STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)
 {
  static const IID* arr[] =
  {
   &IID_IReports,
  };
  for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++)
  {
   if (::InlineIsEqualGUID(*arr[i], riid))
    return S_OK;
  }
  return S_FALSE;
 }

// IViewObjectEx
 DECLARE_VIEW_STATUS(0)

// IReports
public:
 BOOL m_bEnabled;

 enum { IDD = IDD_REPORTS };

Quote:
};

#endif //__REPORTS_H_


Fri, 30 Jul 2004 23:54:45 GMT  
 MMC Snapin with OCX Resultview failed to create control
Your control throws a C++ exception somewhere. Set ActiveX Test
Container as executable for debugging session (Project | Settings |
Debug) and run your control under de{*filter*}. It shold break on exception
and show you the source.
--
With best wishes,
    Igor Tandetnik

"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken


Quote:
> We're developing an MMC Snapin and would like two OCX Resultviews.
What we
> have done is to a develop ActiveX Controls as part of the same library
file,
> so that the whole dll is self contained and self sufficient.

> The first OCX control was developed and instantiates from ActiveX Test
> Container as expected.

> The second one was inserted exactly the same way the first one was
(VC++
> Menu Insert/New ATL Object).  With the second one however, we get the
error:

> 'Failed to create control: Unspecified Error'

> We have seen the KB support article, Q122792
> ( http://www.*-*-*.com/ ;EN-GB;q221792), and
have
> implemented these changed in the control constructor.  However, this
is not
> the problem, as when we debug the project, execution never reaches the
> constructor.

> Instead, in the debug window, we can see this:

> First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363:
Microsoft
> C++ Exception.
> First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363:
Microsoft
> C++ Exception.
> First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363:
Microsoft
> C++ Exception.

> Some extra debugging we did was to insert the ActiveX Control files
into a
> new project.  They worked.  Is it something to do with the fact we are
> developing an MMC Snapin and already have one control in the dll .idl
file?

> Appreciate any help given.

> Thanks

> -- ActiveX Object header file: Reports.h ---

> // Reports.h : Declaration of the CReports

> #ifndef __REPORTS_H_
> #define __REPORTS_H_

> #include "resource.h"       // main symbols
> #include <atlctl.h>

////////////////////////////////////////////////////////////////////////
////

- Show quoted text -

Quote:
> /
> // CReports
> class ATL_NO_VTABLE CReports :
>  public CComObjectRootEx<CComSingleThreadModel>,
>  public CStockPropImpl<CReports, IReports, &IID_IReports,
&LIBID_WKSNMGMT>,
>  public CComCompositeControl<CReports>,
>  public IPersistStreamInitImpl<CReports>,
>  public IOleControlImpl<CReports>,
>  public IOleObjectImpl<CReports>,
>  public IOleInPlaceActiveObjectImpl<CReports>,
>  public IViewObjectExImpl<CReports>,
>  public IOleInPlaceObjectWindowlessImpl<CReports>,
>  public ISupportErrorInfo,
>  public IPersistStorageImpl<CReports>,
>  public ISpecifyPropertyPagesImpl<CReports>,
>  public IQuickActivateImpl<CReports>,
>  public IDataObjectImpl<CReports>,
>  public IProvideClassInfo2Impl<&CLSID_Reports, NULL, &LIBID_WKSNMGMT>,
>  public CComCoClass<CReports, &CLSID_Reports>
> {
> public:
>  CReports()
>  {
>   m_bWindowOnly = TRUE;
>   CalcExtent(m_sizeExtent);

>   IDispatchImpl<IReports, &IID_IReports, &LIBID_WKSNMGMT, 1,
> 0>::_tih.m_wMajor = 2;
>   IDispatchImpl<IReports, &IID_IReports, &LIBID_WKSNMGMT, 1,
> 0>::_tih.m_wMinor = 5;

>  }

> DECLARE_REGISTRY_RESOURCEID(IDR_REPORTS)

> DECLARE_PROTECT_FINAL_CONSTRUCT()

> BEGIN_COM_MAP(CReports)
>  COM_INTERFACE_ENTRY(IReports)
>  COM_INTERFACE_ENTRY(IDispatch)
>  COM_INTERFACE_ENTRY(IViewObjectEx)
>  COM_INTERFACE_ENTRY(IViewObject2)
>  COM_INTERFACE_ENTRY(IViewObject)
>  COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
>  COM_INTERFACE_ENTRY(IOleInPlaceObject)
>  COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
>  COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
>  COM_INTERFACE_ENTRY(IOleControl)
>  COM_INTERFACE_ENTRY(IOleObject)
>  COM_INTERFACE_ENTRY(IPersistStreamInit)
>  COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
>  COM_INTERFACE_ENTRY(ISupportErrorInfo)
>  COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
>  COM_INTERFACE_ENTRY(IQuickActivate)
>  COM_INTERFACE_ENTRY(IPersistStorage)
>  COM_INTERFACE_ENTRY(IDataObject)
>  COM_INTERFACE_ENTRY(IProvideClassInfo)
>  COM_INTERFACE_ENTRY(IProvideClassInfo2)
> END_COM_MAP()

> BEGIN_PROP_MAP(CReports)
>  PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
>  PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
>  PROP_ENTRY("Enabled", DISPID_ENABLED, CLSID_NULL)
>  // Example entries
>  // PROP_ENTRY("Property Description", dispid, clsid)
>  // PROP_PAGE(CLSID_StockColorPage)
> END_PROP_MAP()

> BEGIN_MSG_MAP(CReports)
>  CHAIN_MSG_MAP(CComCompositeControl<CReports>)
> END_MSG_MAP()
> // Handler prototypes:
> //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam,
BOOL&
> bHandled);
> //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl,
BOOL&
> bHandled);
> //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

> BEGIN_SINK_MAP(CReports)
>  //Make sure the Event Handlers have __stdcall calling convention
> END_SINK_MAP()

>  STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
>  {
>   if (dispid == DISPID_AMBIENT_BACKCOLOR)
>   {
>    SetBackgroundColorFromAmbient();
>    FireViewChange();
>   }
>   return IOleControlImpl<CReports>::OnAmbientPropertyChange(dispid);
>  }

> // ISupportsErrorInfo
>  STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)
>  {
>   static const IID* arr[] =
>   {
>    &IID_IReports,
>   };
>   for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++)
>   {
>    if (::InlineIsEqualGUID(*arr[i], riid))
>     return S_OK;
>   }
>   return S_FALSE;
>  }

> // IViewObjectEx
>  DECLARE_VIEW_STATUS(0)

> // IReports
> public:
>  BOOL m_bEnabled;

>  enum { IDD = IDD_REPORTS };
> };

> #endif //__REPORTS_H_



Sat, 31 Jul 2004 06:49:37 GMT  
 MMC Snapin with OCX Resultview failed to create control
Yes, I should have said yesterday.  I've already done this.  It throws an
exception in the assembly code under TSTCON32.  So there's no way of my
knowing what exactly is wrong (unless there is the debugging symbols for
Test Container somewhere.


Quote:
> Your control throws a C++ exception somewhere. Set ActiveX Test
> Container as executable for debugging session (Project | Settings |
> Debug) and run your control under de{*filter*}. It shold break on exception
> and show you the source.
> --
> With best wishes,
>     Igor Tandetnik

> "For every complex problem, there is a solution that is simple, neat,
> and wrong." H.L. Mencken



> > We're developing an MMC Snapin and would like two OCX Resultviews.
> What we
> > have done is to a develop ActiveX Controls as part of the same library
> file,
> > so that the whole dll is self contained and self sufficient.

> > The first OCX control was developed and instantiates from ActiveX Test
> > Container as expected.

> > The second one was inserted exactly the same way the first one was
> (VC++
> > Menu Insert/New ATL Object).  With the second one however, we get the
> error:

> > 'Failed to create control: Unspecified Error'

> > We have seen the KB support article, Q122792
> > ( http://www.*-*-*.com/ ;EN-GB;q221792), and
> have
> > implemented these changed in the control constructor.  However, this
> is not
> > the problem, as when we debug the project, execution never reaches the
> > constructor.

> > Instead, in the debug window, we can see this:

> > First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363:
> Microsoft
> > C++ Exception.
> > First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363:
> Microsoft
> > C++ Exception.
> > First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363:
> Microsoft
> > C++ Exception.

> > Some extra debugging we did was to insert the ActiveX Control files
> into a
> > new project.  They worked.  Is it something to do with the fact we are
> > developing an MMC Snapin and already have one control in the dll .idl
> file?

> > Appreciate any help given.

> > Thanks

> > -- ActiveX Object header file: Reports.h ---

> > // Reports.h : Declaration of the CReports

> > #ifndef __REPORTS_H_
> > #define __REPORTS_H_

> > #include "resource.h"       // main symbols
> > #include <atlctl.h>

> ////////////////////////////////////////////////////////////////////////
> ////
> > /
> > // CReports
> > class ATL_NO_VTABLE CReports :
> >  public CComObjectRootEx<CComSingleThreadModel>,
> >  public CStockPropImpl<CReports, IReports, &IID_IReports,
> &LIBID_WKSNMGMT>,
> >  public CComCompositeControl<CReports>,
> >  public IPersistStreamInitImpl<CReports>,
> >  public IOleControlImpl<CReports>,
> >  public IOleObjectImpl<CReports>,
> >  public IOleInPlaceActiveObjectImpl<CReports>,
> >  public IViewObjectExImpl<CReports>,
> >  public IOleInPlaceObjectWindowlessImpl<CReports>,
> >  public ISupportErrorInfo,
> >  public IPersistStorageImpl<CReports>,
> >  public ISpecifyPropertyPagesImpl<CReports>,
> >  public IQuickActivateImpl<CReports>,
> >  public IDataObjectImpl<CReports>,
> >  public IProvideClassInfo2Impl<&CLSID_Reports, NULL, &LIBID_WKSNMGMT>,
> >  public CComCoClass<CReports, &CLSID_Reports>
> > {
> > public:
> >  CReports()
> >  {
> >   m_bWindowOnly = TRUE;
> >   CalcExtent(m_sizeExtent);

> >   IDispatchImpl<IReports, &IID_IReports, &LIBID_WKSNMGMT, 1,
> > 0>::_tih.m_wMajor = 2;
> >   IDispatchImpl<IReports, &IID_IReports, &LIBID_WKSNMGMT, 1,
> > 0>::_tih.m_wMinor = 5;

> >  }

> > DECLARE_REGISTRY_RESOURCEID(IDR_REPORTS)

> > DECLARE_PROTECT_FINAL_CONSTRUCT()

> > BEGIN_COM_MAP(CReports)
> >  COM_INTERFACE_ENTRY(IReports)
> >  COM_INTERFACE_ENTRY(IDispatch)
> >  COM_INTERFACE_ENTRY(IViewObjectEx)
> >  COM_INTERFACE_ENTRY(IViewObject2)
> >  COM_INTERFACE_ENTRY(IViewObject)
> >  COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
> >  COM_INTERFACE_ENTRY(IOleInPlaceObject)
> >  COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
> >  COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
> >  COM_INTERFACE_ENTRY(IOleControl)
> >  COM_INTERFACE_ENTRY(IOleObject)
> >  COM_INTERFACE_ENTRY(IPersistStreamInit)
> >  COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
> >  COM_INTERFACE_ENTRY(ISupportErrorInfo)
> >  COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
> >  COM_INTERFACE_ENTRY(IQuickActivate)
> >  COM_INTERFACE_ENTRY(IPersistStorage)
> >  COM_INTERFACE_ENTRY(IDataObject)
> >  COM_INTERFACE_ENTRY(IProvideClassInfo)
> >  COM_INTERFACE_ENTRY(IProvideClassInfo2)
> > END_COM_MAP()

> > BEGIN_PROP_MAP(CReports)
> >  PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
> >  PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
> >  PROP_ENTRY("Enabled", DISPID_ENABLED, CLSID_NULL)
> >  // Example entries
> >  // PROP_ENTRY("Property Description", dispid, clsid)
> >  // PROP_PAGE(CLSID_StockColorPage)
> > END_PROP_MAP()

> > BEGIN_MSG_MAP(CReports)
> >  CHAIN_MSG_MAP(CComCompositeControl<CReports>)
> > END_MSG_MAP()
> > // Handler prototypes:
> > //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam,
> BOOL&
> > bHandled);
> > //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl,
> BOOL&
> > bHandled);
> > //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

> > BEGIN_SINK_MAP(CReports)
> >  //Make sure the Event Handlers have __stdcall calling convention
> > END_SINK_MAP()

> >  STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
> >  {
> >   if (dispid == DISPID_AMBIENT_BACKCOLOR)
> >   {
> >    SetBackgroundColorFromAmbient();
> >    FireViewChange();
> >   }
> >   return IOleControlImpl<CReports>::OnAmbientPropertyChange(dispid);
> >  }

> > // ISupportsErrorInfo
> >  STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)
> >  {
> >   static const IID* arr[] =
> >   {
> >    &IID_IReports,
> >   };
> >   for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++)
> >   {
> >    if (::InlineIsEqualGUID(*arr[i], riid))
> >     return S_OK;
> >   }
> >   return S_FALSE;
> >  }

> > // IViewObjectEx
> >  DECLARE_VIEW_STATUS(0)

> > // IReports
> > public:
> >  BOOL m_bEnabled;

> >  enum { IDD = IDD_REPORTS };
> > };

> > #endif //__REPORTS_H_



Sat, 31 Jul 2004 15:26:29 GMT  
 MMC Snapin with OCX Resultview failed to create control
You can build it yourself - it comes as a sample...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.*-*-*.com/
=====================================

Quote:

> Yes, I should have said yesterday.  I've already done this.  It throws an
> exception in the assembly code under TSTCON32.  So there's no way of my
> knowing what exactly is wrong (unless there is the debugging symbols for
> Test Container somewhere.



> > Your control throws a C++ exception somewhere. Set ActiveX Test
> > Container as executable for debugging session (Project | Settings |
> > Debug) and run your control under de{*filter*}. It shold break on exception
> > and show you the source.
> > --
> > With best wishes,
> >     Igor Tandetnik

> > "For every complex problem, there is a solution that is simple, neat,
> > and wrong." H.L. Mencken



> > > We're developing an MMC Snapin and would like two OCX Resultviews.
> > What we
> > > have done is to a develop ActiveX Controls as part of the same library
> > file,
> > > so that the whole dll is self contained and self sufficient.

> > > The first OCX control was developed and instantiates from ActiveX Test
> > > Container as expected.

> > > The second one was inserted exactly the same way the first one was
> > (VC++
> > > Menu Insert/New ATL Object).  With the second one however, we get the
> > error:

> > > 'Failed to create control: Unspecified Error'

> > > We have seen the KB support article, Q122792
> > > ( http://www.*-*-*.com/ ;EN-GB;q221792), and
> > have
> > > implemented these changed in the control constructor.  However, this
> > is not
> > > the problem, as when we debug the project, execution never reaches the
> > > constructor.

> > > Instead, in the debug window, we can see this:

> > > First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363:
> > Microsoft
> > > C++ Exception.
> > > First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363:
> > Microsoft
> > > C++ Exception.
> > > First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363:
> > Microsoft
> > > C++ Exception.

> > > Some extra debugging we did was to insert the ActiveX Control files
> > into a
> > > new project.  They worked.  Is it something to do with the fact we are
> > > developing an MMC Snapin and already have one control in the dll .idl
> > file?

> > > Appreciate any help given.

> > > Thanks

> > > -- ActiveX Object header file: Reports.h ---

> > > // Reports.h : Declaration of the CReports

> > > #ifndef __REPORTS_H_
> > > #define __REPORTS_H_

> > > #include "resource.h"       // main symbols
> > > #include <atlctl.h>

> > ////////////////////////////////////////////////////////////////////////
> > ////
> > > /
> > > // CReports
> > > class ATL_NO_VTABLE CReports :
> > >  public CComObjectRootEx<CComSingleThreadModel>,
> > >  public CStockPropImpl<CReports, IReports, &IID_IReports,
> > &LIBID_WKSNMGMT>,
> > >  public CComCompositeControl<CReports>,
> > >  public IPersistStreamInitImpl<CReports>,
> > >  public IOleControlImpl<CReports>,
> > >  public IOleObjectImpl<CReports>,
> > >  public IOleInPlaceActiveObjectImpl<CReports>,
> > >  public IViewObjectExImpl<CReports>,
> > >  public IOleInPlaceObjectWindowlessImpl<CReports>,
> > >  public ISupportErrorInfo,
> > >  public IPersistStorageImpl<CReports>,
> > >  public ISpecifyPropertyPagesImpl<CReports>,
> > >  public IQuickActivateImpl<CReports>,
> > >  public IDataObjectImpl<CReports>,
> > >  public IProvideClassInfo2Impl<&CLSID_Reports, NULL, &LIBID_WKSNMGMT>,
> > >  public CComCoClass<CReports, &CLSID_Reports>
> > > {
> > > public:
> > >  CReports()
> > >  {
> > >   m_bWindowOnly = TRUE;
> > >   CalcExtent(m_sizeExtent);

> > >   IDispatchImpl<IReports, &IID_IReports, &LIBID_WKSNMGMT, 1,
> > > 0>::_tih.m_wMajor = 2;
> > >   IDispatchImpl<IReports, &IID_IReports, &LIBID_WKSNMGMT, 1,
> > > 0>::_tih.m_wMinor = 5;

> > >  }

> > > DECLARE_REGISTRY_RESOURCEID(IDR_REPORTS)

> > > DECLARE_PROTECT_FINAL_CONSTRUCT()

> > > BEGIN_COM_MAP(CReports)
> > >  COM_INTERFACE_ENTRY(IReports)
> > >  COM_INTERFACE_ENTRY(IDispatch)
> > >  COM_INTERFACE_ENTRY(IViewObjectEx)
> > >  COM_INTERFACE_ENTRY(IViewObject2)
> > >  COM_INTERFACE_ENTRY(IViewObject)
> > >  COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
> > >  COM_INTERFACE_ENTRY(IOleInPlaceObject)
> > >  COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
> > >  COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
> > >  COM_INTERFACE_ENTRY(IOleControl)
> > >  COM_INTERFACE_ENTRY(IOleObject)
> > >  COM_INTERFACE_ENTRY(IPersistStreamInit)
> > >  COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
> > >  COM_INTERFACE_ENTRY(ISupportErrorInfo)
> > >  COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
> > >  COM_INTERFACE_ENTRY(IQuickActivate)
> > >  COM_INTERFACE_ENTRY(IPersistStorage)
> > >  COM_INTERFACE_ENTRY(IDataObject)
> > >  COM_INTERFACE_ENTRY(IProvideClassInfo)
> > >  COM_INTERFACE_ENTRY(IProvideClassInfo2)
> > > END_COM_MAP()

> > > BEGIN_PROP_MAP(CReports)
> > >  PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
> > >  PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
> > >  PROP_ENTRY("Enabled", DISPID_ENABLED, CLSID_NULL)
> > >  // Example entries
> > >  // PROP_ENTRY("Property Description", dispid, clsid)
> > >  // PROP_PAGE(CLSID_StockColorPage)
> > > END_PROP_MAP()

> > > BEGIN_MSG_MAP(CReports)
> > >  CHAIN_MSG_MAP(CComCompositeControl<CReports>)
> > > END_MSG_MAP()
> > > // Handler prototypes:
> > > //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam,
> > BOOL&
> > > bHandled);
> > > //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl,
> > BOOL&
> > > bHandled);
> > > //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

> > > BEGIN_SINK_MAP(CReports)
> > >  //Make sure the Event Handlers have __stdcall calling convention
> > > END_SINK_MAP()

> > >  STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
> > >  {
> > >   if (dispid == DISPID_AMBIENT_BACKCOLOR)
> > >   {
> > >    SetBackgroundColorFromAmbient();
> > >    FireViewChange();
> > >   }
> > >   return IOleControlImpl<CReports>::OnAmbientPropertyChange(dispid);
> > >  }

> > > // ISupportsErrorInfo
> > >  STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)
> > >  {
> > >   static const IID* arr[] =
> > >   {
> > >    &IID_IReports,
> > >   };
> > >   for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++)
> > >   {
> > >    if (::InlineIsEqualGUID(*arr[i], riid))
> > >     return S_OK;
> > >   }
> > >   return S_FALSE;
> > >  }

> > > // IViewObjectEx
> > >  DECLARE_VIEW_STATUS(0)

> > > // IReports
> > > public:
> > >  BOOL m_bEnabled;

> > >  enum { IDD = IDD_REPORTS };
> > > };

> > > #endif //__REPORTS_H_



Sun, 01 Aug 2004 07:02:25 GMT  
 MMC Snapin with OCX Resultview failed to create control
Thanks

Will try


You can build it yourself - it comes as a sample...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.*-*-*.com/
=====================================


Quote:
> Yes, I should have said yesterday.  I've already done this.  It throws an
> exception in the assembly code under TSTCON32.  So there's no way of my
> knowing what exactly is wrong (unless there is the debugging symbols for
> Test Container somewhere.



> > Your control throws a C++ exception somewhere. Set ActiveX Test
> > Container as executable for debugging session (Project | Settings |
> > Debug) and run your control under de{*filter*}. It shold break on exception
> > and show you the source.
> > --
> > With best wishes,
> >     Igor Tandetnik

> > "For every complex problem, there is a solution that is simple, neat,
> > and wrong." H.L. Mencken



> > > We're developing an MMC Snapin and would like two OCX Resultviews.
> > What we
> > > have done is to a develop ActiveX Controls as part of the same library
> > file,
> > > so that the whole dll is self contained and self sufficient.

> > > The first OCX control was developed and instantiates from ActiveX Test
> > > Container as expected.

> > > The second one was inserted exactly the same way the first one was
> > (VC++
> > > Menu Insert/New ATL Object).  With the second one however, we get the
> > error:

> > > 'Failed to create control: Unspecified Error'

> > > We have seen the KB support article, Q122792
> > > ( http://www.*-*-*.com/ ;EN-GB;q221792), and
> > have
> > > implemented these changed in the control constructor.  However, this
> > is not
> > > the problem, as when we debug the project, execution never reaches the
> > > constructor.

> > > Instead, in the debug window, we can see this:

> > > First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363:
> > Microsoft
> > > C++ Exception.
> > > First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363:
> > Microsoft
> > > C++ Exception.
> > > First-chance exception in TSTCON32.EXE (KERNEL32.DLL): 0xE06D7363:
> > Microsoft
> > > C++ Exception.

> > > Some extra debugging we did was to insert the ActiveX Control files
> > into a
> > > new project.  They worked.  Is it something to do with the fact we are
> > > developing an MMC Snapin and already have one control in the dll .idl
> > file?

> > > Appreciate any help given.

> > > Thanks

> > > -- ActiveX Object header file: Reports.h ---

> > > // Reports.h : Declaration of the CReports

> > > #ifndef __REPORTS_H_
> > > #define __REPORTS_H_

> > > #include "resource.h"       // main symbols
> > > #include <atlctl.h>

> > ////////////////////////////////////////////////////////////////////////
> > ////
> > > /
> > > // CReports
> > > class ATL_NO_VTABLE CReports :
> > >  public CComObjectRootEx<CComSingleThreadModel>,
> > >  public CStockPropImpl<CReports, IReports, &IID_IReports,
> > &LIBID_WKSNMGMT>,
> > >  public CComCompositeControl<CReports>,
> > >  public IPersistStreamInitImpl<CReports>,
> > >  public IOleControlImpl<CReports>,
> > >  public IOleObjectImpl<CReports>,
> > >  public IOleInPlaceActiveObjectImpl<CReports>,
> > >  public IViewObjectExImpl<CReports>,
> > >  public IOleInPlaceObjectWindowlessImpl<CReports>,
> > >  public ISupportErrorInfo,
> > >  public IPersistStorageImpl<CReports>,
> > >  public ISpecifyPropertyPagesImpl<CReports>,
> > >  public IQuickActivateImpl<CReports>,
> > >  public IDataObjectImpl<CReports>,
> > >  public IProvideClassInfo2Impl<&CLSID_Reports, NULL, &LIBID_WKSNMGMT>,
> > >  public CComCoClass<CReports, &CLSID_Reports>
> > > {
> > > public:
> > >  CReports()
> > >  {
> > >   m_bWindowOnly = TRUE;
> > >   CalcExtent(m_sizeExtent);

> > >   IDispatchImpl<IReports, &IID_IReports, &LIBID_WKSNMGMT, 1,
> > > 0>::_tih.m_wMajor = 2;
> > >   IDispatchImpl<IReports, &IID_IReports, &LIBID_WKSNMGMT, 1,
> > > 0>::_tih.m_wMinor = 5;

> > >  }

> > > DECLARE_REGISTRY_RESOURCEID(IDR_REPORTS)

> > > DECLARE_PROTECT_FINAL_CONSTRUCT()

> > > BEGIN_COM_MAP(CReports)
> > >  COM_INTERFACE_ENTRY(IReports)
> > >  COM_INTERFACE_ENTRY(IDispatch)
> > >  COM_INTERFACE_ENTRY(IViewObjectEx)
> > >  COM_INTERFACE_ENTRY(IViewObject2)
> > >  COM_INTERFACE_ENTRY(IViewObject)
> > >  COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
> > >  COM_INTERFACE_ENTRY(IOleInPlaceObject)
> > >  COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
> > >  COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
> > >  COM_INTERFACE_ENTRY(IOleControl)
> > >  COM_INTERFACE_ENTRY(IOleObject)
> > >  COM_INTERFACE_ENTRY(IPersistStreamInit)
> > >  COM_INTERFACE_ENTRY2(IPersist, IPersistStreamInit)
> > >  COM_INTERFACE_ENTRY(ISupportErrorInfo)
> > >  COM_INTERFACE_ENTRY(ISpecifyPropertyPages)
> > >  COM_INTERFACE_ENTRY(IQuickActivate)
> > >  COM_INTERFACE_ENTRY(IPersistStorage)
> > >  COM_INTERFACE_ENTRY(IDataObject)
> > >  COM_INTERFACE_ENTRY(IProvideClassInfo)
> > >  COM_INTERFACE_ENTRY(IProvideClassInfo2)
> > > END_COM_MAP()

> > > BEGIN_PROP_MAP(CReports)
> > >  PROP_DATA_ENTRY("_cx", m_sizeExtent.cx, VT_UI4)
> > >  PROP_DATA_ENTRY("_cy", m_sizeExtent.cy, VT_UI4)
> > >  PROP_ENTRY("Enabled", DISPID_ENABLED, CLSID_NULL)
> > >  // Example entries
> > >  // PROP_ENTRY("Property Description", dispid, clsid)
> > >  // PROP_PAGE(CLSID_StockColorPage)
> > > END_PROP_MAP()

> > > BEGIN_MSG_MAP(CReports)
> > >  CHAIN_MSG_MAP(CComCompositeControl<CReports>)
> > > END_MSG_MAP()
> > > // Handler prototypes:
> > > //  LRESULT MessageHandler(UINT uMsg, WPARAM wParam, LPARAM lParam,
> > BOOL&
> > > bHandled);
> > > //  LRESULT CommandHandler(WORD wNotifyCode, WORD wID, HWND hWndCtl,
> > BOOL&
> > > bHandled);
> > > //  LRESULT NotifyHandler(int idCtrl, LPNMHDR pnmh, BOOL& bHandled);

> > > BEGIN_SINK_MAP(CReports)
> > >  //Make sure the Event Handlers have __stdcall calling convention
> > > END_SINK_MAP()

> > >  STDMETHOD(OnAmbientPropertyChange)(DISPID dispid)
> > >  {
> > >   if (dispid == DISPID_AMBIENT_BACKCOLOR)
> > >   {
> > >    SetBackgroundColorFromAmbient();
> > >    FireViewChange();
> > >   }
> > >   return IOleControlImpl<CReports>::OnAmbientPropertyChange(dispid);
> > >  }

> > > // ISupportsErrorInfo
> > >  STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid)
> > >  {
> > >   static const IID* arr[] =
> > >   {
> > >    &IID_IReports,
> > >   };
> > >   for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++)
> > >   {
> > >    if (::InlineIsEqualGUID(*arr[i], riid))
> > >     return S_OK;
> > >   }
> > >   return S_FALSE;
> > >  }

> > > // IViewObjectEx
> > >  DECLARE_VIEW_STATUS(0)

> > > // IReports
> > > public:
> > >  BOOL m_bEnabled;

> > >  enum { IDD = IDD_REPORTS };
> > > };

> > > #endif //__REPORTS_H_



Sun, 01 Aug 2004 20:26:29 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. OCX Control from a MMC snapin (2)

2. How to debug Active X control shown by MMC Snapin

3. MMC Snapin

4. ATL MMC Snapins

5. MMC Snapin

6. MMC-Snapin

7. MMC Snapin

8. How to stop MMC close SnapIn window

9. MMC Snapin, refresh prob.

10. check box in MMC SnapIn

11. CheckBox in MMC SnapIn

12. Novice: Use ATL for MMC snapin?

 

 
Powered by phpBB® Forum Software