3

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.

user7116
  • 63,008
  • 17
  • 141
  • 172
Seth Carnegie
  • 73,875
  • 22
  • 181
  • 249

1 Answers1

4

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.

Neverbirth
  • 1,044
  • 8
  • 20
  • And I can't even remember why I needed to do this. Thanks very much for the answer though, I'll keep it in mind for when I remember :) – Seth Carnegie Aug 04 '11 at 11:56
  • Heh, I didn't even realize this question was a couple of months old, well, it may be of help to other people in the future as well. – Neverbirth Aug 04 '11 at 12:06
  • @Neverbirth Got a question about the OcxState: http://stackoverflow.com/questions/8735616/activex-initialization-axhost-state-object – Felix K. Jan 06 '12 at 09:32