-1

I want to open a multiple C++ .exe application inside my C# WPF application GUI to show multiple live videostreams coming from multiple IP camera's.

I've tried looking into Interops but can't find an example that actually works for me.

My goal is to load the .exe into the C# WPF application GUI without window borders, close buttons, etc... and have it fixed in one place.

Laurens
  • 23
  • 5
  • So you don't want to run an exe, you want to embed it in a window in your application? – Reinstate Monica Cellio Jul 09 '19 at 09:11
  • Yes If that makes more sense – Laurens Jul 09 '19 at 09:14
  • 1
    Well it's a totally different thing, and one that you're not going to achieve. You can't run an application inside your own application. If you have access to components or assemblies that the application uses then *maybe* you could do something, but it's a painful and obscure task. You need to rethink your solution - it's not going to happen. – Reinstate Monica Cellio Jul 09 '19 at 09:15
  • 2
    I think you'd be better off trying to understand how to render the IP camera data in your C# WPF app directly, instead of trying to mash applications together like this. – AndreasHassing Jul 09 '19 at 09:18
  • It _is_ possible, but this is so much more complex that one would think. If you continue to chase this solution, you are likely going to spend many many hours on it with no success guaranteed. I recommend: Give up now and take a different approach as suggested in comments above. – nada Jul 09 '19 at 09:24
  • I've tried that but at a certain amount of camera's the application starts showing a lot of latency. The IP Camera's are from mobotix and they have a player.exe written in C++ with their own MxPeg compression. That is the reason why I wanted to do that – Laurens Jul 09 '19 at 09:25
  • @Laurens What do you mean by _certain amount of cameras_? – nada Jul 09 '19 at 09:27
  • Then this is an XY_Problem. You're actually trying to reduce camera latency am I right? You should probably post a question about your real problem then. – nada Jul 09 '19 at 09:29
  • Here's an example of getting the feed and displaying it yourself... https://stackoverflow.com/questions/15408404/ip-cam-live-feed-from-c-sharp . As mentioned already, if lag is your issue then that's a different issue, but deal with each issue separately. – Reinstate Monica Cellio Jul 09 '19 at 09:37

1 Answers1

0

Technically, Windows GUI works fine across processes.

Change C++ app so it receives a command-line argument like ownerHwnd=0FE321, and sets up new video window as a child of the window handle passes in that argument.

Change WPF app so it creates HwndHost One per camera is probably the simplest one. Or you can use single one per app, and position multiple video streams on that window. Pass HwndHost’s window handle to the C++ app when starting streams. Write code to handle resize. Don't forget to listen for Exited event and react somehow.

The tricky part is IPC between these processes. You can’t call functions, and there’re also threading issues, like input focus (if your video renderer doesn’t need user input, should be fine). One good IPC strategy for this case is sending/posting/responding to custom windows messages. Changing the C++ project into the DLL with a single exported function helps with that, but at the cost of stability.

Soonts
  • 20,079
  • 9
  • 57
  • 130