开发者

Manually creating a Flash AxHost.OcxState

开发者 https://www.devze.com 2023-03-12 23:17 出处:网络
I am trying to use the AxShockwaveFlashObjects.AxShockwaveFlash object in a console application in C#.To do that, you have to set the obj.OcxState to something. I looked at how the Forms designer does

I am trying to use the AxShockwaveFlashObjects.AxShockwaveFlash object in a console application in C#. To do that, you have to set the obj.OcxState to something. I looked at how the Forms designer does that, and it does it this way:

this.flash.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("flash.OcxState")));

I looked in resources and there is nothing there.

My question is, how can I create an AxHost.State manually so I can set the OcxState of my flash object to it?

I see that the constructor of a State takes a Stream, int, bool, and a strin开发者_Go百科g. But I don't know what to put in the Stream (or the int, bool, or string) to create it.


I love this question :P, because setting the OcxState lets you dynamically load a Flash movie from a stream in memory, something I've seen asked here and there without a reply ever (maybe it is now, dunno). I realized about this two years ago while working on an important project, and left it aside for three or so hours until I got this working.

As the stream you can use any stream, a MemoryStream is enough (in order to fill it you can use a BinaryWriter), to set the OcxState just do:

flashCtl.OcxState = new AxHost.State(stream, 1, false, null);

If the resources file has the OcxState entry empty, maybe it is because the Flash OCX lets you set an empty stream with no problems, that's something I don't know.

0

精彩评论

暂无评论...
验证码 换一张
取 消