Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Using a resource from an ATL COM MFC Component

Using a resource from an ATL COM MFC Component

Scheduled Pinned Locked Moved C / C++ / MFC
c++comhelpquestionlearning
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cmacgowan
    wrote on last edited by
    #1

    Hi ... I am expanding on a ATL Addin Framework from thomas_tom99. http://www.codeproject.com/com/AddinProjectFramework.asp To summarize the Addin Framework includes ATL COM (with MFC) Addin Components. The host application will use the Addin Manager to look for registered COM components with the matching CATAGORY ID and then load them into the host application. The Addin Components work nice. The Addin Components are ATL COM with MFC. I would like to add a CFormView based object to the Addin and then access and use the view by my SDI MFC host application. // Forms below are in DLLs. We will need to get the handle for the // resource in the DLL while the view is in use (selected) hDLL = GetModuleHandle("Addin1.dll"); hEXE = AfxGetResourceHandle(); AfxSetResourceHandle((HINSTANCE) hDLL); m_nAddin1View0 = m_wndHorSplitter.AddView(1, 0, RUNTIME_CLASS(CAddin1View0), pContext); AfxSetResourceHandle(hEXE); I get the following error: MainFrm.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CAddin1View0::classCAddin1View0" (?classCAddin1View0@CAddin1View0@@2UCRuntimeClass@@B) I have done this in the past with a standard MFC DLL. ?? --------------------- Here is the addin and host code: In Addin1.dll I have added the CFormView derived CAddin1View0 class. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ class CAddin1View0 : public CFormView { protected: CAddin1View0(); // protected constructor used by dynamic creation DECLARE_DYNCREATE(CAddin1View0) // Form Data public: //{{AFX_DATA(CAddin1View0) enum { IDD = IDD_ADDIN1_VIEW0 }; // NOTE: the ClassWizard will add data members here //}}AFX_DATA // Attributes public: // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAddin1View0) public: virtual void OnInitialUpdate(); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: virtual ~CAddin1View0(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif // Generated message map functions //{{AFX_MSG(CAddin1View0) // NOTE - the ClassWizard will add and remove member functions here. //}}AFX_MSG DECLARE_MESSAGE_MAP() }; In the host application I have a window splitter and would like one of four views to show in the horizontal pane. I have created three test views

    C 1 Reply Last reply
    0
    • C cmacgowan

      Hi ... I am expanding on a ATL Addin Framework from thomas_tom99. http://www.codeproject.com/com/AddinProjectFramework.asp To summarize the Addin Framework includes ATL COM (with MFC) Addin Components. The host application will use the Addin Manager to look for registered COM components with the matching CATAGORY ID and then load them into the host application. The Addin Components work nice. The Addin Components are ATL COM with MFC. I would like to add a CFormView based object to the Addin and then access and use the view by my SDI MFC host application. // Forms below are in DLLs. We will need to get the handle for the // resource in the DLL while the view is in use (selected) hDLL = GetModuleHandle("Addin1.dll"); hEXE = AfxGetResourceHandle(); AfxSetResourceHandle((HINSTANCE) hDLL); m_nAddin1View0 = m_wndHorSplitter.AddView(1, 0, RUNTIME_CLASS(CAddin1View0), pContext); AfxSetResourceHandle(hEXE); I get the following error: MainFrm.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CAddin1View0::classCAddin1View0" (?classCAddin1View0@CAddin1View0@@2UCRuntimeClass@@B) I have done this in the past with a standard MFC DLL. ?? --------------------- Here is the addin and host code: In Addin1.dll I have added the CFormView derived CAddin1View0 class. \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ class CAddin1View0 : public CFormView { protected: CAddin1View0(); // protected constructor used by dynamic creation DECLARE_DYNCREATE(CAddin1View0) // Form Data public: //{{AFX_DATA(CAddin1View0) enum { IDD = IDD_ADDIN1_VIEW0 }; // NOTE: the ClassWizard will add data members here //}}AFX_DATA // Attributes public: // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CAddin1View0) public: virtual void OnInitialUpdate(); protected: virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support //}}AFX_VIRTUAL // Implementation protected: virtual ~CAddin1View0(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif // Generated message map functions //{{AFX_MSG(CAddin1View0) // NOTE - the ClassWizard will add and remove member functions here. //}}AFX_MSG DECLARE_MESSAGE_MAP() }; In the host application I have a window splitter and would like one of four views to show in the horizontal pane. I have created three test views

      C Offline
      C Offline
      cmacgowan
      wrote on last edited by
      #2

      Hi ... I have fixed the problem by adding the __declspec (dllexport) to the CAddin1View0 class definition. I forgot to add this. Then you have to include the Addin1.lib in the project and then the application will require the Addin1.dll to be present ... this defeats the purpose of using the ATL COM Addin ... Where I can unregister the component and the host application does not care that it is missing. I will continue to search for a method to expose the pointer to the a CRuntimeClass using the COM interface. ??? Any ideas ?? Thanks, Chris // the ADDIN1_DLL must be set in the project preprocessor // definitions. This can be found in the project setting and the // c/c++ tab. If you leave this out you will get some warnings. #ifdef ADDIN1_DLL #define Addin1DLLSpec __declspec (dllexport) #else #define Addin1DLLSpec __declspec (dllimport) #endif class Addin1DLLSpec CAddin1View0 : public CFormView

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups