简体   繁体   English

如何从URL初始化ActiveX控件?

[英]How can I initialize an ActiveX control from a URL?

I have an MFC ActiveX control embedded in a web page. 我在网页中嵌入了MFC ActiveX控件。 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. 这个想法是浏览器将从Web服务器检索资源并将其传递给控件。 The browser's own caching would then take care of the unneccesary downloads. 然后,浏览器自己的缓存将处理不必要的下载。 Unfortunately, ref parameters don't work like this. 不幸的是,ref参数不能像这样工作。 The browser just passes the url along to the control (which strikes me as utterly useless , but I digress). 浏览器只是将URL传递给控件(这使我感到毫无用处 ,但我离题了)。

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? 另外,在MFC中是否有一种简单的方法来指示控件的宿主容器检索URI标识的资源? Any better ideas? 还有更好的主意吗?

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> . 实现IPersistStream或IPersistStreamInit接口,然后可以使用对象的data属性指定内容,如: <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. Internet Explorer将通过其IPersistStream :: Load接口将数据属性引用的文件下载给您。 ATL has default implementations for these interfaces which will populate your control's properties, almost certainly so does MFC. ATL具有这些接口的默认实现,这些实现将填充控件的属性,而MFC几乎可以肯定。

Does it really need the data when it is created? 创建数据时,它真的需要数据吗?

Could you make it an 'init' step 您能否将其设为“初始”步骤

largeData = GetData();
MyActiveX.init( largeData );

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM