views:

135

answers:

3

I am building a C++ (Qt) based application for controlling a flash based UI. Because the flash runtime leaks spectatular amounts of memory, we execute the UI as a .swf loaded in the standalone flash player separate from the command-and-control app written i C++.

The C++ starts the flash player as an external process with appropriate parameters, and communicates with it over a TCP socket connected to localhost.

The application runs primarily on Windows XP and above.

The unfortunate side effect of running the flash player standalone is that two applications are shown in the Alt+tab list as well as in the task bar on windows (one being our application, the other being the flash player). Additionally, as the application runs full screen, flash must manage the entire screen. Allowing the C++ app to draw parts of the screen would be a massive improvement.

We would like to somehow merge the two, while leaving our own application in control. I am thinking something along the lines of Google Chrome, which appears to be running each browser tab in a separate process while displaying all output in a single window.

I've been reading up in the Win32 API (and google) in order to determine if accomplishing this is even possible. Althogh so far I've come up with dll injection as the only semi-viable solution, but I would very much like to consider that plan B.

Any suggestions would be appreciated.

A: 

I guess this question and its answers are related to your question: Embedding Flash Player in a C++ or Java application?

Emile Vrijdags
A: 

DLL injection won't get you anywhere, the memory would still be allocated in your main process if you're instantiating the flash player as an in-process server.
If you want to keep control over the memory leaks you have to keep the flash player in a seperate process.

Your current approach sounds viable, your only problem seems to be that the process is still visible in something like the Alt+Tab list... as far as i recall, setting the extended window style to WS_EX_TOOLWINDOW should help you with that.
For hiding the process from the taskbar see e.g. here.

Georg Fritzsche
+2  A: 

The Alt+Tab list shows top-level (no parent) windows that are visible and don't have the WS_EX_TOOLWINDOW extended style. So if you have two windows from two processes but you only want to see one in the Alt-Tab list (and on the task bar), then you have a few options:

  1. Add the WS_EX_TOOLWINDOW to one of the windows.

  2. Re-parent one of the windows to a hidden top-level window.

  3. Re-parent one of the windows (probably the Flash player) to the other window. This is tricky, but it's probably how Chrome and many other multi-process single-window apps work. What makes it tricky is handling the lifetimes of the windows and inadvertently serializing the message queues.

Adrian McCarthy
Thanks a lot for your answer. Your first suggestion appears trivial to implement, it essentially boils down to calling FindWindow() and SetWindowLongPtr(). So far so good.Your third suggestion however appears to be the most potent, especially in conjunction with http://qt.nokia.com/doc/solutions/4/qtwinmigrate/winmigrate-win32-in-qt-example.htmlI can't seem to figure out how reparenting is done though. The only reference to setting a parent window that I can find, is in the CreateWindow() documentation.Can you provide me with a place to start?
Søren Boll Overgaard
`SetParent()`: http://msdn.microsoft.com/en-us/library/ms633541(VS.85).aspx
Adrian McCarthy