Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually creating a Flash AxHost.OcxState

Tags:

c#

flash

interop

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 string. But I don't know what to put in the Stream (or the int, bool, or string) to create it.

like image 699
Seth Carnegie Avatar asked Jul 08 '26 21:07

Seth Carnegie


1 Answers

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.

like image 197
Neverbirth Avatar answered Jul 11 '26 14:07

Neverbirth



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!