COM object wrapper not creating a function 
Author Message
 COM object wrapper not creating a function

First of all, let me state for the record that I am just a beginner when
it comes to COM objects and ActiveX programming. I'm building a COM-
object which is implemented in another application that I'm writing at
the same time. It has been working well until now.

I have a property that previously was only read, but I had to change it
to be read/ write. So I hacked my way into the files, not knowing any
other way. The COM project compiles without any errors, but when I create
the wrapper class for the COM object in my other app, the new function is
not there... Why?

Some code:
==========

project.idl

// This has allways been there.
[propget, id(14), helpstring("property ValidThru")] HRESULT ValidThru
([out, retval] BSTR* pVal);
// This is the new one, that doesn't get used.
[propput, id(14), helpstring("property ValidThru")] HRESULT ValidThru
([in] BSTR newVal);

project.h

STDMETHOD( get_ValidThru ) ( BSTR* a_psVal );
STDMETHOD( put_ValidThru ) ( BSTR a_sVal );

project.cpp

STDMETHODIMP CT_EPresentkort::get_ValidThru( BSTR* a_psVal )
{
        AFX_MANAGE_STATE( AfxGetStaticModuleState() );
        USES_CONVERSION;

        char sTmp[5];
        memset( sTmp, '\0', 5 );

        m_ctEPresentkortDll.GetValidThru( sTmp );
        SysFreeString( *a_psVal );
        *a_psVal = SysAllocString( A2W( sTmp ) );

        return S_OK;

Quote:
}

STDMETHODIMP CT_EPresentkort::put_ValidThru( BSTR a_sVal )
{
        AFX_MANAGE_STATE( AfxGetStaticModuleState() );
        USES_CONVERSION;

        if( NULL != a_sVal )
                m_ctEPresentkortDll.SetGiltigTom( W2A( a_sVal ) );
        else
                m_ctEPresentkortDll.SetGiltigTom( "" );
        return S_OK;

Quote:
}



Sun, 18 Dec 2005 02:16:12 GMT  
 COM object wrapper not creating a function
Apparently trouble not in you COM server (you code is
right) but occur in time when you make wraper class.
You can watch in OLE view  utility type library of you
object, and if there contained defintion of propput and
propget methods then trouble actualy in a way creating of
you wrapper class (also you may check definition of this
method in type library in VB)

Quote:
>-----Original Message-----
>First of all, let me state for the record that I am just
a beginner when
>it comes to COM objects and ActiveX programming. I'm
building a COM-
>object which is implemented in another application that
I'm writing at
>the same time. It has been working well until now.

>I have a property that previously was only read, but I
had to change it
>to be read/ write. So I hacked my way into the files, not
knowing any
>other way. The COM project compiles without any errors,
but when I create
>the wrapper class for the COM object in my other app, the
new function is
>not there... Why?

>Some code:
>==========

>project.idl

>// This has allways been there.
>[propget, id(14), helpstring("property ValidThru")]
HRESULT ValidThru
>([out, retval] BSTR* pVal);
>// This is the new one, that doesn't get used.
>[propput, id(14), helpstring("property ValidThru")]
HRESULT ValidThru
>([in] BSTR newVal);

>project.h

>STDMETHOD( get_ValidThru ) ( BSTR* a_psVal );
>STDMETHOD( put_ValidThru ) ( BSTR a_sVal );

>project.cpp

>STDMETHODIMP CT_EPresentkort::get_ValidThru( BSTR*
a_psVal )
>{
>    AFX_MANAGE_STATE( AfxGetStaticModuleState() );
>    USES_CONVERSION;

>    char sTmp[5];
>    memset( sTmp, '\0', 5 );

>    m_ctEPresentkortDll.GetValidThru( sTmp );
>    SysFreeString( *a_psVal );
>    *a_psVal = SysAllocString( A2W( sTmp ) );

>    return S_OK;
>}

>STDMETHODIMP CT_EPresentkort::put_ValidThru( BSTR a_sVal )
>{
>    AFX_MANAGE_STATE( AfxGetStaticModuleState() );
>    USES_CONVERSION;

>    if( NULL != a_sVal )
>            m_ctEPresentkortDll.SetGiltigTom( W2A(
a_sVal ) );
>    else
>            m_ctEPresentkortDll.SetGiltigTom( "" );
>    return S_OK;
>}
>.



Sun, 18 Dec 2005 14:06:15 GMT  
 COM object wrapper not creating a function
When looking at my COM server with OLE/COM Object Viewer, the
propput isn't there, so it's logical that the wrapper can't
find it. If the code is correct, why doesn't the propput get
included in the COM object? Not even if I let the wizard create
the property it works (thought that when entering it manually I
missed something). In fact it did exactly the same as I (not
too much of a surprise I think).



Quote:
> Apparently trouble not in you COM server (you code is
> right) but occur in time when you make wraper class.
> You can watch in OLE view  utility type library of you
> object, and if there contained defintion of propput and
> propget methods then trouble actualy in a way creating of
> you wrapper class (also you may check definition of this
> method in type library in VB)

>>-----Original Message-----
>>First of all, let me state for the record that I am just
> a beginner when
>>it comes to COM objects and ActiveX programming. I'm
> building a COM-
>>object which is implemented in another application that
> I'm writing at
>>the same time. It has been working well until now.

>>I have a property that previously was only read, but I
> had to change it
>>to be read/ write. So I hacked my way into the files, not
> knowing any
>>other way. The COM project compiles without any errors,
> but when I create
>>the wrapper class for the COM object in my other app, the
> new function is
>>not there... Why?

>>Some code:
>>==========

>>project.idl

>>// This has allways been there.
>>[propget, id(14), helpstring("property ValidThru")]
> HRESULT ValidThru
>>([out, retval] BSTR* pVal);
>>// This is the new one, that doesn't get used.
>>[propput, id(14), helpstring("property ValidThru")]
> HRESULT ValidThru
>>([in] BSTR newVal);

>>project.h

>>STDMETHOD( get_ValidThru ) ( BSTR* a_psVal );
>>STDMETHOD( put_ValidThru ) ( BSTR a_sVal );

>>project.cpp

>>STDMETHODIMP CT_EPresentkort::get_ValidThru( BSTR*
> a_psVal )
>>{
>>     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
>>     USES_CONVERSION;

>>     char sTmp[5];
>>     memset( sTmp, '\0', 5 );

>>     m_ctEPresentkortDll.GetValidThru( sTmp );
>>     SysFreeString( *a_psVal );
>>     *a_psVal = SysAllocString( A2W( sTmp ) );

>>     return S_OK;
>>}

>>STDMETHODIMP CT_EPresentkort::put_ValidThru( BSTR a_sVal )
>>{
>>     AFX_MANAGE_STATE( AfxGetStaticModuleState() );
>>     USES_CONVERSION;

>>     if( NULL != a_sVal )
>>          m_ctEPresentkortDll.SetGiltigTom( W2A(
> a_sVal ) );
>>     else
>>          m_ctEPresentkortDll.SetGiltigTom( "" );
>>     return S_OK;
>>}
>>.



Sun, 18 Dec 2005 14:33:39 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Creating COM objects from COM objects

2. Confused regarding apartments, when COM objects are forced by COM to be created and when shared

3. Create instance of an com object inside a the Com server

4. Creating VC++ built COM application in VB - resulting in - ActiveX can't create object

5. Creating a wrapper function for eVB

6. Detecting if a function exists in a DLL for a COM object (specifically DirectX object)

7. Attributes not created when ConstructorInfo.Invoke used to create object

8. Return a pointer to a nested COM object from a COM object method

9. Invoking COM object from COM object

10. passing COM object pointers to another COM object in ATL

11. COM Object returning COM Object Reference

12. COM object in a COM object

 

 
Powered by phpBB® Forum Software