一个窗口可以总是位于另一个窗口之上吗? [英] Can a window be always on top of just one other window?

查看:28
本文介绍了一个窗口可以总是位于另一个窗口之上吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Windows 中,是否可以将窗口 A 设置为始终位于窗口 B 的顶部,但允许其他窗口正常工作并在活动时出现在两者的顶部.

In Windows, is it possible to set window A such that it is always on top of window B, yet allow other windows to work as normal and appear over the top of both, when active.

换句话说,我想要两个窗口之间的父子关系.这可以在不使窗口 A 成为窗口 B 的子窗口的情况下完成吗,MDI 风格?窗口 B 不是我的 (Internet Explorer),当我尝试使用 SetParent 实现这一点时,我的对话框 A 的图形被搞砸了.

In other words, I want a parent-child relationship between two windows. Can this be done without making window A a child of window B, MDI-style? Window B isn't mine (Internet Explorer), and screws my dialog A's graphics up when I try to achieve this with SetParent.

我以为我已经从 MSDN 论坛帖子,但遗憾的是,Windows A 始终位于所有内容之上,而不仅仅是窗口 B.

I thought I'd cracked it with this idea from an MSDN forum post, but alas windows A is still always on top of everything, not just window B.

// Place window A on top
SetWindowPos(hWndWindow, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE);
// Place window B underneath it
SetWindowPos(hWndParent, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);

有可能吗?

推荐答案

创建所有权关系不会解决问题吗?

Wouldn't creating an ownership relationship do the trick?

SetWindowLong(hwndChild, GWL_HWNDPARENT, hwndOwner)

窗口可以在不同的进程中,您可以从任何进程调用它.这将确保子窗口始终位于所有者窗口上方.这与实际创建父/子关系的 SetParent 不同.通读这篇文章(来自 1993 年,但大部分仍然正确)以查看所有权和养育子女的区别.

The windows can be in different processes and you can call this from any process. This will ensure that the child window is always above the owner window. This is different than SetParent which actually creates a Parent / Child relationship. Read through this article (its from 1993 but still mostly correct) to see the distinction between ownership and parenting.

这篇关于一个窗口可以总是位于另一个窗口之上吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆