tags:

views:

24

answers:

2

I have an MFC ActiveX control embedded in a web page. Some of the parameters for this control are very large. I don't know what these values will be at compile time, but I do know that once retrieved, they will almost certainly never change.

Currently, I embed the parameters like so:

<object name="MyActiveX">
  <param name="param" value="<%= GetData() %>" />
</object>

I want to do something like this:

<object name="MyActiveX">
  <param name="param" value="content/data" valuetype="ref" />
</object>

The idea is that the browser would retrieve the resource from the web server and pass it on to the control. The browser's own caching would then take care of the unneccesary downloads. Unfortunately, ref parameters don't work like this. The browser just passes the url along to the control (which strikes me as utterly useless, but I digress).

So, is there some way I can make this work? Alternatively, is there an easy way in MFC to instruct the control's host container to retrieve a URI identified resource? Any better ideas?

A: 

Does it really need the data when it is created?

Could you make it an 'init' step

largeData = GetData();
MyActiveX.init( largeData );
Greg Domjan
It doesn't. I could write some code to retrieve the data using WinINet or something similar, but I'd like to avoid making extensive changes to the ActiveX (the codebase is shared with other projects, and making ActiveX-specific changes is ugly).
Peter Ruderman
+1  A: 

Implement the IPersistStream or IPersistStreamInit interface then you can specify content with the object's data attribute as in: <object clsid="XXXX" data="mydata.bin"></object>. Internet Explorer will download the file referenced by the data attribute hand it to you via its IPersistStream::Load interface. ATL has default implementations for these interfaces which will populate your control's properties, almost certainly so does MFC.

tyranid
This seems to be going in the right direction. The archive attribute seems more appropriate since there may be multiple items to download. How does IE expose the data in this case?
Peter Ruderman
Really if you want to download multiple items then this isn't going to be what you want, IE will only ever download one file (referenced by data=), all other params are ignored. You really should just take in a set of parameters and download it yourself. Use something like http://www.codeguru.com/cpp/i-n/internet/activex/article.php/c6151 to get the current hosted URL.If you are initializing properties of the controls then the IPersist stuff will work (looking at it MFC implements default IPerist interfaces). http://msdn.microsoft.com/en-us/library/xxf9wx2c%28v=VS.100%29.aspx
tyranid
DoPropExchange is how I'm currently grabbing the parameters from the param tags. I'm not sure if it can read out the data from IPersistStream. Maybe the way to go is just to serialize all the data into a single download. Thanks for your help!
Peter Ruderman