Board index » cppbuilder » ActiveX Server Object properties will not Set or Get.

ActiveX Server Object properties will not Set or Get.


2004-02-20 09:50:48 AM
cppbuilder75
I created a ActiveX Server Object that I can access from ASP.
But Methods below do not set the property or retrieve the value, because as the ASP code below demonstrates I set property1 to equal 999, but return value 0.
STDMETHODIMP TTESTImpl::_set_Property1(long* Value)
{
try
{
Value = &p;
}
catch(Exception &e)
{
return Error(e.Message.c_str(), IID_ITEST);
}
return S_OK;
};
STDMETHODIMP TTESTImpl::get_Property1(long* Value)
{
try
{
Value = &p;
}
catch(Exception &e)
{
return Error(e.Message.c_str(), IID_ITEST);
}
return S_OK;
};
STDMETHODIMP TTESTImpl::set_Property1(long Value)
{
try
{
p = Value;
}
catch(Exception &e)
{
return Error(e.Message.c_str(), IID_ITEST);
}
return S_OK;
};
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
ASP CODE
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<HTML>
<HEAD>
<TITLE>Testing C++Builder ASP </TITLE>
</HEAD>
<BODY>
<CENTER>
<H3>You should see the results of your C++Builder Active Server method below </H3>
</CENTER>
<HR>
<% Set CBuilderASPObj = Server.CreateObject("Project1.test")
CBuilderASPObj.property1=999
response.write CBuilderASPObj.property1
%>
<HR>
</BODY>
</HTML>
 
 

Re:ActiveX Server Object properties will not Set or Get.

"Fernando Villa" < XXXX@XXXXX.COM >wrote in message
Quote
STDMETHODIMP TTESTImpl::_set_Property1(long* Value)
STDMETHODIMP TTESTImpl::set_Property1(long Value)
Why do you have 2 setter methods?
Quote
Value = &p;
That is not the correct way to return a value, you should be dereferencing
the pointer instead:
*Value = p;
Gambit
 

Re:ActiveX Server Object properties will not Set or Get.

I found some of your examples on the internet. I tried your susgest, no change.
 

{smallsort}

Re:ActiveX Server Object properties will not Set or Get.

"Fernando Villa" < XXXX@XXXXX.COM >wrote in message
Quote
I found some of your examples on the internet. I
tried your susgest, no change.
Then there is something else wrong with your code that you have not shown
yet, because what I suggested earlier should work fine:
// get rid of _set_Property1() altogether
STDMETHODIMP TTESTImpl::get_Property1(long* Value)
{
try
{
*Value = p;
}
catch(Exception &e)
{
return Error(e.Message.c_str(), IID_ITEST);
}
return S_OK;
};
STDMETHODIMP TTESTImpl::set_Property1(long Value)
{
try
{
p = Value;
}
catch(Exception &e)
{
return Error(e.Message.c_str(), IID_ITEST);
}
return S_OK;
};
Gambit
 

Re:ActiveX Server Object properties will not Set or Get.

I think unloading the DLL helped, because the properties work now. Now the methods do not return values.
STDMETHODIMP TMyTestImpl::Method1(VARIANT* Param1)
{
return 111;
}
STDMETHODIMP TMyTestImpl::get_Property1(long* Value)
{
try
{
*Value = p;
}
catch(Exception &e)
{
return Error(e.Message.c_str(), IID_IMyTest);
}
return S_OK;
};
STDMETHODIMP TMyTestImpl::set_Property1(long Value)
{
try
{
p = Value;
}
catch(Exception &e)
{
return Error(e.Message.c_str(), IID_IMyTest);
}
return S_OK;
};
STDMETHODIMP TMyTestImpl::get_Property2(long* Value)
{
try
{
*Value = p;
}
catch(Exception &e)
{
return Error(e.Message.c_str(), IID_IMyTest);
}
return S_OK;
};
STDMETHODIMP TMyTestImpl::Method2(VARIANT* Param1)
{
return 222;}
STDMETHODIMP TMyTestImpl::set_Property2(long Value)
{
try
{
p = Value;
}
catch(Exception &e)
{
return Error(e.Message.c_str(), IID_IMyTest);
}
return S_OK;
};
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Asp Code
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<HTML>
<HEAD>
<TITLE>Testing C++Builder ASP </TITLE>
</HEAD>
<BODY>
<CENTER>
<H3>You should see the results of your C++Builder Active Server method below </H3>
</CENTER>
<HR>
<% Set CBuilderASPObj = Server.CreateObject("Project1.MyTest")
CBuilderASPObj.property1=888
dim x,y
y=1
y = CBuilderASPObj.Method2(y)
x = CBuilderASPObj.property1
response.write x
%>
<HR>
</BODY>
</HTML>
 

Re:ActiveX Server Object properties will not Set or Get.

"Fernando Villa" < XXXX@XXXXX.COM >wrote in message
Quote
Now the methods do not return values.
Nor should they, because you did not set them up to have any return values
in the first place. To return a value, you must use an [out, retval]
parameter, just like you had to for the property getters. You do not use
the HRESULT return value because that value is never seen by the script. It
is for COM's internal error handling only.
STDMETHODIMP TMyTestImpl::Method1(VARIANT Param1 /*[in]*/, VARIANT*
Result /*[out,retval]*/)
{
try
{
//...
VariantInit(Result);
Result->vt = VT_I4;
Result->lVal = 111;
//...
}
catch(Exception &e)
{
return Error(e.Message.c_str(), IID_IMyTest);
}
return S_OK;
}
Gambit