0

I want to open in my main window 3rd party application, for example office, or adobe reader.

Something like this. This example is in windows forms. Embeded application

But I can use only pure c++ with winapi. Is it possible? What can I use for it. Can you give me some example?

Thanks

x22
  • 541
  • 2
  • 7
  • 1
    Unless the applications are prepared to be hosted inside another window, you cannot safely do this. None of the applications you named are prepared for this. – IInspectable Jul 29 '15 at 14:30
  • I am aware of MDI in windows, that allows to create child windows inside the MDI client window. But except with virtualization, I do not know how to force the top level window of an application to be a child window. Maybe you could try to create a window station or simply a desktop, and use your window as a wrapper around it. Or maybe you only need OLE which is **much** simpler even if already tricky. Currently your question (including the example) is *unclear*. – Serge Ballesta Jul 29 '15 at 14:55

1 Answers1

1

You can do this by identifying the window's handle (HWND) of the application to be embedded. Then you can re-parent that window into the host window using SetParent function of the Window API. Window handles are 32-bits so this will work even between 32/64 bits processes.

Attention should be payed however to dispatch events correctly from the host application to the embedded window (for example when re-sizing or hiding the host, the embedded window should be re-sized or hidden as well). And also position the embedded window inside the host.

Here is an example of this approach

This may work fine with notepad, but more complex applications can manifest strange behavior when re-parented to another process window, but you can experiment.

Archie
  • 2,644
  • 21
  • 21