[英]Borderless window activated event not fired when minimize-restore from taskbar icon
I have a borderless window
with resize mode set to canMinimize
我有一个borderless window
,调整大小模式设置为canMinimize
WindowStyle="None"
ResizeMode="CanMinimize"
When I change my window state
to minimized on some button click and restore from taskbar icon then window's activated event is fired. 当我将window state
更改为最小化时,单击某个按钮并从任务栏图标恢复,然后触发窗口的激活事件。
But when I minimize window from taskbar icon and restore from taskbar icon click then my window does not fire activated event. 但是,当我从任务栏图标最小化窗口并从任务栏图标单击恢复时,我的窗口不会激活激活的事件。
This has nothing to do with the window style. 这与窗口样式无关。 You can try the other styles too and you will observe the same behavior. 您也可以尝试其他样式,您将观察到相同的行为。
The underlying window activation logic is based on the Windows' messages. 底层窗口激活逻辑基于Windows的消息。 When you click on the taskbar icon of an active window, the following messages will be sent to the window: 单击活动窗口的任务栏图标时,将向窗口发送以下消息:
WM_ACTIVATE
( MSDN ) with wParam
containing WA_INACTIVE
+ not minimized WM_ACTIVATE
( MSDN ),其中wParam
包含WA_INACTIVE
+ 未最小化 followed by: 其次是:
WM_ACTIVATE
with wParam
containing WA_ACTIVE
+ minimized WM_ACTIVATE
使用包含WA_ACTIVE
+的wParam
最小化 This causes the WPF window to raise the Activated
event even if the window has actually been minimized ( see that WA_ACTIVE
state? ) When you click on the taskbar icon one more time, the window will be restored and will receive the message: 这会导致WPF窗口提升Activated
事件,即使窗口实际上已被最小化( 请参阅WA_ACTIVE
状态? )当您WA_ACTIVE
单击任务栏图标时,窗口将被恢复并将收到消息:
WM_ACTIVATE
with wParam
containing WA_ACTIVE
+ not minimized 包含WA_ACTIVE
+的wParam
WM_ACTIVATE
未最小化 But since the window "was" already active, there will be no Activated
event. 但由于窗口“已经”已经激活,因此不存在Activated
事件。 I would consider it as a Windows' bug ( why would we receive a WA_ACTIVE
state even if the window is minimized? ) Maybe you can ask Microsoft about that. 我认为这是一个Windows'错误( 为什么即使窗口被最小化,我们也会收到WA_ACTIVE
状态? )也许你可以向微软询问这个问题。
To overcome this problem, you might use the StateChanged
event instead and check the window's state ( WindowState.Minimized
vs. WindowsState.Normal
). 要解决此问题,可以使用StateChanged
事件并检查窗口的状态( WindowState.Minimized
与WindowsState.Normal
)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.