Is there a way to launch a 3rd party program as a child window of your program?

Started by
1 comment, last by HellRaider 23 years, 10 months ago
Is there a way to launch a 3rd party program as a child window of your program? I.E: Open 2 instances of the Notepad program as a child window inside my program. The Notepad is only an example, the program I''d like to use is much more complex (it''s a 2D game using DX7). I''ve seen some programs doing something similar to what I want to do. If it''s possible to make it... how much would the program slow down? I have no idea if it''s possible or not. If it''s impossible, pardon me for my ignorance :D. Thanks in advance!
Advertisement
It''s real easy, first you need the hwnd from the window you want inside another window.If the window you want is from a different application, you can use FindWindow to get it, if its a window from the current application, you can figure out a way to get it without FindWindow (shouldn''t be hard; if worst comes to worst you can always use a global).FindWindow works like this

HWND FindWindow(char *windowclassname,char *windowtitle)

you can use the spy program to find out class names for other programs.Also note this will only find the first window with the specified class name; if multiple windows exist with the same class name, it''ll only return the first one it finds (it searches in z-order, so it would be the topmost window of the same class).
Now you have the hwnd, use the SetParent function

HWND SetParent(HWND window,HWND newparent)

window is the window you want to be inside your window, and newparent is your window.The return HWND is the window''s old parent window, which you can use to un-set it with.You make also want to use MoveWindow to position it inside your window.
As far as slowing things down, it shouldn''t; The application''s thread will still be different from yours.
If the window does not yet exist (i.e., your program is executing the program) you can use ShellExecute to run the program and specify your window as the parent window.

Good luck
----------meh
Jesus, that was easy! LOL

It worked!

I handn''t tried that function because it''s documentation at MSDN says it can only be used to set the parent window of a child window you currently own inside your app.

Thanks a lot bro!

This topic is closed to new replies.

Advertisement