Tag Archives: SetParent
Host a process window inside your applications window
The following snippet will allow you to host the window of any application inside your own application. This isn’t a recommended practice but it’s a fun method that might spawn some interesting ideas.
In order to get this working we will need to pinvoke two Win32 functions, SetParent
and SetWindowPos
.
Place the following lines in your class
1 2 3 4 | [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); [DllImport("user32.dll", EntryPoint = "SetWindowPos")] public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags); |