C# 创建窗口 - 定义父窗口
我想使用 C#
窗口创建,并将父级设置为我定义的句柄, 这是其他进程的窗口句柄。
有人知道该怎么做吗?
问候,
I want create using C#
window with setted parent to my defined handle,
this is a other process window handle.
Anyone know how to do this?
Greetings,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果我正确理解你的问题,你应该能够通过使用类似这样的东西来实现你想要的:
这会将
MainForm
变成指定窗口的子窗口,使其始终出现在其上方。我在示例中使用了ShowDialog
,但这也适用于Show
。这是特定于 Windows 窗体的。在 WPF 中,您可以尝试以下操作:
在显示 WPF 窗口后,我快速尝试了此操作,它似乎按预期工作,但 WPF 知识不是那么好。
If I understood your question correctly you should be able to achieve what you want by using something like this:
This will turn
MainForm
a child window of the specified window making it always appear above it. I useShowDialog
in the example, but this should also work forShow
. This is specific for Windows Forms.In WPF you can try the following:
I quickly tried this after showing the WPF window and it seemed to work as expected, but WPF knowledge is not that great.
我相信句柄将是只读的;因此,
.Parent
属性是只读的。但是,.Owner
属性有一个 getter 和一个 setter (参考 MSDN) ...但是,您必须有对父窗口的引用。如果没有更多信息,我将无法提供更多信息。如果您的父候选人是一个非托管窗口,请检查此链接。
I believe the Handle will be read-only; therefore, the
.Parent
property is read-only. However, the.Owner
property has a getter and a setter (ref. MSDN) ... however, you must have a reference to the Parent window.Without more information, I will not be able to provide much more than that.If your parent candidate is an unmanaged Window, check this link.