Click to See Complete Forum and Search --> : suspend activex flash during fscommand
brandon8863
September 1st, 2005, 09:31 PM
I've created a simple C++ MFC project in VC7. I added an activex shockwave flash com object to the project dialog and added the fscommand event.
When I handle the fscommand from C++, is there a way to suspend the Activex flash thread in the App until right before I send the setVariable command to the control? This would make the fscommand much easier to deal with since you wouldn't have all the callbacks in ActionScript2.
Any ideas?
Thanks,
B--
Siddhartha
September 2nd, 2005, 08:26 AM
Have you created the thread yourself? Do you have a handle to it?
brandon8863
September 3rd, 2005, 12:34 PM
I have created the activex control, but mfc has created the thread. Here is the dialog ini code.
RECT rc;
::GetClientRect(m_hWnd, &rc);
CShockwaveFlash* myFlash = new CShockwaveFlash();
bool bStat;
bStat = m_ControlWrapper.CreateControl(myFlash->GetClsid(), "", WS_VISIBLE, rc, this, 5000, NULL, false, NULL);
I've been looking at ways to get the thread handle from m_ControlWrapper, or myFlash, but no luck. When debugging I can see that MFC has created a thread when the CreateControl is called; I just can't seem to get a handle to the thread so that I can susped it.
B--
Siddhartha
September 4th, 2005, 09:40 AM
To help us help you, please explain this -
When I handle the fscommand from C++, is there a way to suspend the Activex flash thread in the App until right before I send the setVariable command to the control? This would make the fscommand much easier to deal with since you wouldn't have all the callbacks in ActionScript2....These are not standard jargons!
Explain with code, if possible...
brandon8863
September 4th, 2005, 11:41 AM
Let me explain more generally what I'm trying to do. Using a standard MFC project from VS7; I'm wanting to create a thread that will contain and create an existing ActiveX (ShockwaveFlash) control.
Right now the ActiveX control exists inside the main thread, and I can not suspend it without suspending the main program also. Ideally I'm wanting to be able to suspend the activex control thread from the main program thread.
I've tried numerous ways to create an ActiveX control inside a thread outside the main program, but I get access violation errors at runtime.
So, I'm looking for a way to create a new thread outside of the main application thread that creates an activex control which can be suspended without suspending the main application. Make sense? Any ideas?
B--
Siddhartha
September 4th, 2005, 11:53 AM
So, I'm looking for a way to create a new thread outside of the main application thread that creates an activex control which can be suspended without suspending the main application.As you are using MFC, you can create a thread using -
AfxBeginThread (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_afxbeginthread.asp) - note parameter dwCreateFlags that can take value CREATE_SUSPENDED
Additional references -
Codeguru FAQ: How to create a Worker Thread? (http://www.codeguru.com/forum/showthread.php?t=312452)
Codeguru FAQ: Multithreading References (http://www.codeguru.com/forum/showthread.php?p=1222389#post1222389)
brandon8863
September 4th, 2005, 12:18 PM
Thanks for the fast reply. I had read these resources before posting the question here.
The resources you listed mainly deal with accessing some UI 'from' the thread. I need the thread itself to 'create and contain' the UI control; in this case an activex container.
The activex control is running a flash movie that is in itself executing actionscript code. When the flash movie actionscript code 'talks' to the C++ thread, I need the activeX flash movie thread to suspend so that no more flash actionscript code will be executed until I resume the thread that is hosting the activex container from C++.
All the info I've found on threads via MFC deals with the new thread accessing the main thread that contains the control. I'm looking to create a new thread that creates the activex control itself; keeping the execution and update of the activex control within the new thread, separate form the main program thread.
Make sense? I've tried numerous way to 'house' the activex control within a new thread, but I keep getting access violation errors at runtine.
Creating threads, and managing them is not the issue. Having the new thead create and get/send messages to and from the activex control that was created and exists inside the new thread has proved ellusive.
Any ideas or resources covering that?
B--
Siddhartha
September 4th, 2005, 12:39 PM
The resources you listed mainly deal with accessing some UI 'from' the thread. The resources I have listed simply tell different ways to create a thread, nothing more.
The activex control is running a flash movie that is in itself executing actionscript code. When the flash movie actionscript code 'talks' to the C++ thread, I need the activeX flash movie thread to suspend so that no more flash actionscript code will be executed until I resume the thread that is hosting the activex container from C++.I haven't worked with ActionScript, Flash or anything remotely similar to these - so I can't hazard a guess whether this is or is not the best way to do something.
I'm looking to create a new thread that creates the activex control itself; keeping the execution and update of the activex control within the new thread, separate form the main program thread.Again, generally speaking - think of classes that do something specific for you - like updating the ActiveX control, handling events, etc.
Invoke these classes and the methods they expose from another (new) thread.
I've tried numerous way to 'house' the activex control within a new thread, but I keep getting access violation errors at runtine.So, post code that pertains to thread creation and the crash - that'll help.
Better still - as a proof test write a tiny test sample that hosts the control. Then, create a new thread that essentially invokes the basic functionality. If you get the same problem, zip and attach it in your next post.
In general, it is possible to create and show UI, Dialog, etc in the non-main thread.
brandon8863
September 4th, 2005, 01:17 PM
Thanks again for the fast reply. I am working on a simple 'proof' application right now, nothing more. It is very simple, and is only focusing on the fundamental issues.
I have the new thread creating and containing the activex control, I'm just running into issues with Microsofts' DoDataExchange from within the CWinThread. It is causing issues for some reason.. I'm tracking it down now.
I was hoping someone had been here before and would have some insight that would save me the time of having to figure out the details. Thanks again for your replies. As far as I can tell there are no resources covering the details of this endeavor. If/when I get the time to get everything working I'll post a link in this thread with the solution.
Thanks again.
B--
Siddhartha
September 4th, 2005, 01:18 PM
You are welcome...
I am working on a simple 'proof' application right now, nothing more. It is very simple, and is only focusing on the fundamental issues.And this actually is the way to go... ;)
brandon8863
September 5th, 2005, 02:23 PM
Ok, the solution is to lay your framework as follows:
1. Have the main application create a UI thread.
2. The ui thread creates a cdialog class which creates the activex component.
Now on the fscommand from the activex control you have to send 2 messages to get it up to the main app so that it can suspend the thread and deal with the message.
The 2 messages are as follows:
1. activex fscomamnd event fires message to the thread it is running in.
2. Thread that caught the message from cdialog fires a message to main ap p that created the thread.
That's all there is to it. My problem was in the layout. I was creating a cdialog that created a thread with the activex control. It worked, but I could not get the fscommand event working right because it was expecting a cdialog parent, and not a cwinthread parent.
You might be able to get away with firing just one message from the activex control all the way up the the main application. I haven't played with it that much to see if I could get it working with one call.
B--
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.