Making a window be a child of an already existing window

Hey. I've come across a case where I need to make a window I've created in c++ act as the child of another window that already exists (and that I didn't create). That is, it should take on all of the behaviors of child windows, including having its exit method called when the parent window is called.

I've seen applications that have done this, but don't have the clearest idea of how about ot go about it.
If I had the source code for the parent frame, I'm sure it would be easy. But, I don't.

One example technique for doing this that I've seen is through various windows commands. That is, using FindWindow to get a handle to the window:

HWND parentWin = FindWindow(NULL, "Calculator");

and then using SetParent to make the connection. However, I haven't been able to get this working properly so far. The examples I've seen have been mostly incomplete.

If choice of frameworks matters, I suppose .NET may be ideal. However, what would really be ideal is if I could figure out how to do this as a process independent of the framework, so that I could potentially do this for any registered window, regardless of what it was created in.

Any tips, resources, etc.

Thanks



Answer this question

Making a window be a child of an already existing window

  • Raj S

    What you saw was OLE (Object Linking and Embedding).

    Via OLE it is possible to host a complete application inside yours.

    Via normal CLR/Win32 functions it is not possible to host a complete forign application window as a child inside your window!



  • Making a window be a child of an already existing window