Thread: An ATL class as member of another ATL Class

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    8

    An ATL class as member of another ATL Class

    I have an C++ ATL COM DLL (VS2015) with two ATL Clasess, and I would like to add one of them as a member of the other ATL class.

    How should I do it?

    I tried adding the member as the type CMyClass*, MyClass*, IMyClass, also as CComObject<CMyClass>*. But I could do it? An project example could be very usefull but I didn't find any in Internet.

    Thanks in advance

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    It might help if you showed a minimal code example of what you're trying to do, that can be built. Show what you've tried to accomplish your goals, and what errors you received when it failed.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3
    Registered User
    Join Date
    Nov 2005
    Posts
    8
    This is the actual state:

    In idl file:
    Code:
    interface IProblem : IDispatch{
    	[propget, id(1)] HRESULT miProblema([out, retval] ISolver** pVal);
    	[propput, id(1)] HRESULT miProblema([in] ISolver* newVal);
    };
    Definition in private section of Problem.h:
    Code:
    CComObject<CSolver> *pProblema;
    Constructor:
    Code:
    CProblem()
    	{  // THIS RUNS
    		HRESULT hRes = CComObject<CSolver>::CreateInstance(&pProblema);
    		ATLASSERT(SUCCEEDED(hRes));
    		pProblema->AddRef();
    	}
    Definition:
    Code:
    STDMETHODIMP CProblem::get_miProblema(ISolver** pVal)
    {
    // THIS RUNS!!
    	pProblema->QueryInterface(IID_ISolver, (void**)pVal);
    	return S_OK;
    }
    
    
    STDMETHODIMP CProblem::put_miProblema(ISolver* newVal)
    {
     // I DON'T KNOW HOW TO DO THIS
    	return S_OK;
    }

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    This doesn't look like standard C++. Perhaps you'd be better off posting in the windows programming forum. Perhaps a moderator could move the thread.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 11-18-2012, 11:17 AM
  2. Replies: 2
    Last Post: 04-19-2011, 10:03 PM
  3. Can Nested class access parent class's private member?
    By meili100 in forum C++ Programming
    Replies: 4
    Last Post: 06-05-2009, 08:42 AM
  4. Replies: 25
    Last Post: 10-29-2007, 04:08 PM
  5. derived class can not access base class protected member?
    By George2 in forum C++ Programming
    Replies: 2
    Last Post: 10-21-2007, 06:32 PM

Tags for this Thread