如何将应用程序窗口托管为属于另一个进程的窗口的子窗口?

时间:2021-11-18 07:26:00

I would like to host an application window from a process "A" into the main window of a process "B", just as if "A"'s window were a MDI child window. Is this possible in Windows? Or are there some tricks which would allow me to fake this?

我想将进程“A”的应用程序窗口托管到进程“B”的主窗口中,就好像“A”的窗口是MDI子窗口一样。这在Windows中可行吗?或者是否有一些技巧可以让我伪造这个?

By the way, I'd like to remove the title bar (or better yet, all the non-client stuff) of "A"'s window when it is embedded into "B"'s window. I suppose that this must be possible by tweaking the window styles or window classes, but I am by no means an expert in these Win32 intricacies.

顺便说一句,当它嵌入“B”的窗口时,我想删除“A”窗口的标题栏(或者更好的是,所有非客户端的东西)。我认为这必须通过调整窗口样式或窗口类来实现,但我绝不是这些Win32复杂的专家。

1 个解决方案

#1


It's possible to host the Window. Change A's parent HWND by calling the SetParent function against it. To change the window styles, you need to use the GetWindowLong/SetWindowLong pair to change the attributes that you want to muck with.

可以托管Window。通过调用SetParent函数来更改A的父HWND。要更改窗口样式,您需要使用GetWindowLong / SetWindowLong对来更改要使用的属性。

If this is a third-party application (ie, not yours), then you're probably in for a rough ride, particularly if the window does any theming or anything custom with its window (for example, changes to the drag area, etc).

如果这是第三方应用程序(即,不是你的应用程序),那么你可能会遇到困难,特别是如果窗口有任何主题或任何自定义窗口(例如,更改拖动区域等) )。

#1


It's possible to host the Window. Change A's parent HWND by calling the SetParent function against it. To change the window styles, you need to use the GetWindowLong/SetWindowLong pair to change the attributes that you want to muck with.

可以托管Window。通过调用SetParent函数来更改A的父HWND。要更改窗口样式,您需要使用GetWindowLong / SetWindowLong对来更改要使用的属性。

If this is a third-party application (ie, not yours), then you're probably in for a rough ride, particularly if the window does any theming or anything custom with its window (for example, changes to the drag area, etc).

如果这是第三方应用程序(即,不是你的应用程序),那么你可能会遇到困难,特别是如果窗口有任何主题或任何自定义窗口(例如,更改拖动区域等) )。