1

Multiple processes rendering to one window

Two processes, two windows, but one window acts as another window's child window. For example a window contain a edit ctrl, but the edit ctrl is belong to another process. How can I implement such a MFC application?

3 Answers3

0

I don't think having more than one thread managing UI stuff is a good idea at all.

You should just have one thread in charge of the UI (main thread) and create as many working threads as you need. But these working threads do not access UI directly but they notify (SendMessage / PostMessage) the main thread to do the UI work.

Javier De Pedro
  • 2,219
  • 4
  • 32
  • 49
  • 1
    Excuse me, your answer have nothing to do with my question. About my question, chrome is a good example, but I don not have time to read the source code. – Wenbo Huang Aug 24 '11 at 06:54
0

The window and its child must belong to the same process. Period.

What you can do is redirect the output of a process (such as stdout) to a pipe. The GUI process in turns reads the pipe and display the contents into the dedicated child window (edit box or other).

This MSDN article about input/output redirection may help.

Serge Wautier
  • 21,494
  • 13
  • 69
  • 110
  • *"The window and its child must belong to the same process. Period."* - Not quite. Window hierarchies must belong to the same **thread**. Input is virtualized per thread, and each thread has its own dedicated input and message queues. (Note: It is possible - albeit very involved - to spread a GUI across multiple threads, if all participating threads are prepared to deal with window hierarchies that straddle thread boundaries. In that case it doesn't matter, if the threads belong to the same process or to different processes.) – IInspectable Apr 07 '17 at 10:09
  • @IInspectable: Very interesting (even though it would not help the OP in this case). Thanks! – Serge Wautier Apr 07 '17 at 11:54
0

Actually you can achieve this, but has some limitation.

For example, you can embed MS word in your app. The Word window is embedded as a child window in your app. but actually, there is another process winword.exe.

Your app works as compound document container and the embedded one act as compound document server.

Please find "compound document" related stuff from MSDN.