ATL Simple Object in AcitveX Component 
Author Message
 ATL Simple Object in AcitveX Component

I have a ATL Simple Object IExample and want to use it as a property in a
Active X Contol.
I tried to do it like this

IDispatch* m_pDispatch

get_Example(IDispatch** pVal)
{
    pDispatch = m_pDispatch
    (pVal*)->AddRef();

Quote:
}

put_Example(IDispatch* newVal)
{
    pDispatch = newVal;

Quote:
}

This code does not work. It seems like the put- Method would work well, but
in the get - Method I get a exception.

thanks for help

Martin



Thu, 22 May 2003 03:00:00 GMT  
 ATL Simple Object in AcitveX Component
if you insist on not using smart pointers, then it would be

IDispatch* m_pDispatch

get_Example(IDispatch** pVal)
{
        if ( ! pVal ) return E_POINTER ;
        *pVal = m_pDispatch
    (*pVal)->AddRef();
        return S_OK ;

Quote:
}

put_Example(IDispatch* newVal)
{
        if ( m_pDispatch )
                m_pDispatch->Release() ;
    m_pDispatch = newVal;
        m_pDispatch->AddRef() ;
        return S_OK ;

Quote:
}

Using CComPtr<> makes this trivial

CComPtr<IDispatch> m_pDispatch

get_Example(IDispatch** pVal)
{
        return m_pDispatch.CopyTo(pVal) ;

Quote:
}

put_Example(IDispatch* newVal)
{
        m_pDipatch = newVal ;

Quote:
}

Cheers
Simon
www.simon.fell.com/com

On Sun, 3 Dec 2000 19:30:47 +0100, "Dipl.-Ing. Martin Schuller"

Quote:

>I have a ATL Simple Object IExample and want to use it as a property in a
>Active X Contol.
>I tried to do it like this

>IDispatch* m_pDispatch

>get_Example(IDispatch** pVal)
>{
>    pDispatch = m_pDispatch
>    (pVal*)->AddRef();
>}

>put_Example(IDispatch* newVal)
>{
>    pDispatch = newVal;
>}

>This code does not work. It seems like the put- Method would work well, but
>in the get - Method I get a exception.

>thanks for help

>Martin



Thu, 22 May 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Simple ATL Com object problem on simplest examples

2. Returns a ATL Simple object by a method of another ATLSimple object

3. Simple ATL Object-Returning a value to the calling object

4. Problem converting VC6 ATL component to a .NET 2003 VC ATL component

5. Re-use ATL GUI component in another ATL GUI component

6. Simple ATL Apartment Thread Components and Messaging

7. Simple Component Object that supports MFC

8. ATL Active Server Pages Component Wizard - Attributed objects

9. Problems returning an array of objects from an ATL component

10. How to pass vb Object into ATL component

11. ATL Component: Err object in VB???

12. ATL simple object wizard

 

 
Powered by phpBB® Forum Software