gpt4 book ai didi

c# - 有没有办法让窗口包含窗口中的自定义应用程序?

转载 作者:行者123 更新时间:2023-11-28 19:53:49 24 4
gpt4 key购买 nike

这有点奇怪,虽然不完全,但我在想是否有一种方法可以创建一个可以包含自定义应用程序(即 *.exe)的窗口。例如,有一个主窗口,并让它在一个选项卡中包含 Application1,在另一个选项卡中包含 Application2。不确定要准确标记什么,因此只需添加一些可能有用的标记。

最佳答案

这是可以做到的。您可以调用 Win32 函数 SetParent 使应用程序的主窗口成为您的窗口之一的子窗口。

但是,尝试这样做很少有好的结果。其他应用程序总是不希望您执行此操作并且与其不兼容。这样做会对这些进程的输入队列造成严重限制。

Raymond Chen 对此发表了博客:Is it legal to call have a cross-process parent/child or owner/owned window relationship?

Is it technically legal to have a parent/child or owner/owned relationship between windows from different processes?

Yes, it is technically legal.

It is also technically legal to juggle chainsaws.

Creating a cross-thread parent/child or owner/owned window relationship implicitly attaches the input queues of the threads which those windows belong to, and this attachment is transitive: If one of those queues is attached to a third queue, then all three queues are attached to each other. More generally, queues of all windows related by a chain of parent/child or owner/owned or shared-thread relationships are attached to each other.

This gets even more complicated when the parent/child or owner/owned relationship crosses processes, because cross-process coordination is even harder than cross-thread coordination. Sharing variables within a process is much easier than sharing variables across processes. On top of that, some window messages are blocked between processes.

So yes, it is technically legal, but if you create a cross-process parent/child or owner/owned relationship, the consequences can be very difficult to manage. And they become near-impossible to manage if one or both of the windows involved is unaware that it is participating in a cross-process window tree. (I often see this question in the context of somebody who wants to grab a window belonging to another process and forcibly graft it into their own process. That other process was totally unprepared for its window being manipulated in this way, and things may stop working. Indeed, things will definitely stop working if you change that other window from a top-level window to a child window.)

您甚至可以这样做,这是为 16 位 Windows 编写的代码的向后兼容性。它在现代 Windows 中确实没有地位。

关于c# - 有没有办法让窗口包含窗口中的自定义应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22948704/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com