Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
platform
active.directory
adsi
adsi.iis-admin
base
com_ole
complus_mts
component_svcs
database
directx
gdi
graphics_mm
internet.client
internet.server
internet.server.isapi-dev
localization
mapi
messaging
msi
mslayerforunicode
multimedia
networking
networking.ipv6
sdk_install
security
shell
telephony.tapi_2
telephony.tapi_3
telephony.tsp
telephony.wte
tools
ui
ui_shell
win_base_svcs
win16
  
 
date: Thu, 19 Jan 2006 16:38:51 +0100,    group: microsoft.public.platformsdk.com_ole        back       


How to get an ATL ActiveX control working in IE   
Hello,

I created a simple ATL ActiveX control, with one property on the interface:
Url. It is added by clicking some wizard stuf an it creates the following

The IDL describes it as follows:

[propget, id(1), helpstring("property URL")] HRESULT URL([out, retval] 
BSTR* pVal);

[propput, id(1), helpstring("property URL")] HRESULT URL([in] BSTR newVal);

As well as 2 methods:

STDMETHOD(get_URL)(BSTR* pVal);
STDMETHOD(put_URL)(BSTR newVal);

Now, if I call the interface like this in vbscript:

Dim object
Set object = CreateObject("ActiveXTest.testje.1")
object.URL = "http://www.codeguru.com"

My fantastic ATL ActiveX control URL property is invoked!

If I do this in IE:

<OBJECT ID="INXT_ActiveX" WIDTH="100%" HEIGHT="100%" 
CLASSID="CLSID:83CD4A17-89ED-4B7D-A654-22F8E4D6CD0A">
<PARAM NAME="Url" VALUE="http://www.codeguru.com">
</OBJECT>

The Url property is not set. The control is however rendered in IE.

Could someone tell me what I am doing wrong here?

Thanks in advance,
Arthur
date: Thu, 19 Jan 2006 16:38:51 +0100   author:   Arthur Roodenburg

Re: How to get an ATL ActiveX control working in IE   
Arthur Roodenburg  wrote:
> I created a simple ATL ActiveX control, with one property on the
> interface: Url.
>
> If I do this in IE:
>
> <OBJECT ID="INXT_ActiveX" WIDTH="100%" HEIGHT="100%"
> CLASSID="CLSID:83CD4A17-89ED-4B7D-A654-22F8E4D6CD0A">
> <PARAM NAME="Url" VALUE="http://www.codeguru.com">
> </OBJECT>
>
> The Url property is not set. The control is however rendered in IE.

You need to implement IPersistPropertyBag. Since you are using ATL, just 
derive from IPersistPropertyBagImpl, add an entry for 
IPersistPropertyBag to interface map and make sure your property is 
listed in the property map.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Thu, 19 Jan 2006 10:51:12 -0500   author:   Igor Tandetnik

Re: How to get an ATL ActiveX control working in IE   
Igor Tandetnik wrote:
> Arthur Roodenburg  wrote:
> 
>>I created a simple ATL ActiveX control, with one property on the
>>interface: Url.
>>
>>If I do this in IE:
>>
>><OBJECT ID="INXT_ActiveX" WIDTH="100%" HEIGHT="100%"
>>CLASSID="CLSID:83CD4A17-89ED-4B7D-A654-22F8E4D6CD0A">
>><PARAM NAME="Url" VALUE="http://www.codeguru.com">
>></OBJECT>
>>
>>The Url property is not set. The control is however rendered in IE.
> 
> 
> You need to implement IPersistPropertyBag. Since you are using ATL, just 
> derive from IPersistPropertyBagImpl, add an entry for 
> IPersistPropertyBag to interface map and make sure your property is 
> listed in the property map.

Ok thank you very much. That did the trick!

By the way, could someone please explain to me:

1) What does IPeristPropertyBag has to do with my (in principle) non 
persistent Url propertie that is exposed through IDispatch?
2) Why IE does it through this other interface?
3) After al those years I can't rely on the fact that if I create an 
ActiveX control in ATL it actually does what I expect?

Arthur
date: Thu, 19 Jan 2006 17:27:23 +0100   author:   Arthur Roodenburg

Re: How to get an ATL ActiveX control working in IE   
Arthur Roodenburg  wrote:
> 1) What does IPeristPropertyBag has to do with my (in principle) non
> persistent Url propertie that is exposed through IDispatch?

IE feeds the contents of <param> tags to the object via 
IPersistPropertyBag. If the object does not implement one, it cannot see 
its <param> values.

ATL's IPersistPropertyBagImpl implements IPersistPropertyBag::Load as 
follows: it walks the property map, for each property checks whether it 
is present in the bag, and if so reads the value from the bag and 
executes property put on your object's IDispatch implementation.

> 2) Why IE does it through this other interface?

What other interface?

> 3) After al those years I can't rely on the fact that if I create an
> ActiveX control in ATL it actually does what I expect?

Is it a question or a statement? May it be that your expectations were 
wrong?

There is theoretical research into a new computer architecture that 
would ensure programs always meet expectations. A computer in this 
architecture would have just one machine instruction, DWIM (stands for 
Do What I Mean). Unfortunately, this research is very far from fruition. 
Or perhaps it's fortunate, because the moment such computers are 
released you and I would be out of jobs.
-- 
With best wishes,
    Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not 
necessarily a good idea. It is hard to be sure where they are going to 
land, and it could be dangerous sitting under them as they fly 
overhead. -- RFC 1925
date: Thu, 19 Jan 2006 11:46:09 -0500   author:   Igor Tandetnik

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us