c# - NO ACTIVATE 窗口样式

标签 c# c++ windows winapi

我需要一个在我点击它时不会激活但在其他地方应该 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 or SetForegroundWindow function.


否则,如果这不能满足您的要求,您将需要处理 WM_MOUSEACTIVATE message 并返回 MA_NOACTIVATE

关于c# - NO ACTIVATE 窗口样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5140290/

相关文章:

c++ - Gnuplot Windows 在 Ubuntu 中立即消失

java - 在 JNI 中传递对象总是返回 NULL

Python UDP 套接字半随机接收失败

windows - 计划任务是否收到 WM_QUERYENDSESSION 消息?

c# - Entity Framework 重用连接

c# - 继承自 ASP.NET Web 控件 : "Element <name> is not a known element"

c++ - main() 及其参数可以有属性吗?

c# - 为什么我们使用内部类?

c# - 使用静态 Regex.IsMatch 与创建 Regex 实例

c++ - 在多个线程之间安全地共享一个结构