0

Currently I'm using SetParent() to do that. It this "hacky"? is there a better way to do that? if so, how?

here's what I'm using currently:

    void LoadApplication(string path, IntPtr handle)
    {
        var p = Process.Start(path);
        p.WaitForInputIdle();
        Thread.Sleep(1000);
        SetParent(p.MainWindowHandle, handle);
        SetWindowPos(p.MainWindowHandle, 0, 0, 0, 0, 0, 0x0001 | 0x0040);
    } 
Jack
  • 16,276
  • 55
  • 159
  • 284
  • 1
    How else would it be done? They are separate processes so one being within the other is purely a visual thing. The way to make one window a child of another is to set its parent handle, which is exactly what you're doing. If it feels hacky, it's because showing one application window within another's is a hack to begin with. If a hack is what you need then a hack is what you implement. – John May 02 '22 at 06:13
  • See also: https://stackoverflow.com/questions/3459874/good-or-evil-setparent-win32-api-between-different-processes and https://stackoverflow.com/questions/170800/embedding-hwnd-into-external-process-using-setparent – Klaus Gütter May 02 '22 at 09:33

0 Answers0