我需要一个在我点击它时不会激活但在其他地方应该 react 正常的窗口。通常我的意思是如果它上面有一个按钮并且我单击该按钮它应该执行单击并调用单击函数(或事件句柄或其他任何东西)。所以它应该是一个普通的窗口,除了当你与它交互时它不应该被激活。 我知道您可以使用消息过滤器或 Hook 来执行此操作,但是是否有任何窗口样式可以自动执行此操作?
这是针对 Windows 的。
谢谢!
最佳答案
您尝试过 WS_EX_NOACTIVATE
extended window style 吗?
A top-level window created with this style does not become the foreground window when the user clicks it. The system does not bring this window to the foreground when the user minimizes or closes the foreground window.
To activate the window, use the
SetActiveWindow
orSetForegroundWindow
function.
否则,如果这不能满足您的要求,您将需要处理 WM_MOUSEACTIVATE
message 并返回 MA_NOACTIVATE
。
关于c# - NO ACTIVATE 窗口样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5140290/