用于重定向最小化动画的 Win32 C API
我见过 RocketDock 在 Vista 中重定向最小化动画,因此窗口最小化到 Dock,我只是好奇这是如何完成的。实际的最小化动画是重定向到 Dock,还是像一个钩子一样阻止 Windows 最小化窗口,而 RocketDock 在窗口最小化时有一个自定义动画?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我正在开发一个名为“OpenMMT”的开源多显示器任务栏项目。我最近发现(通过许多令人头痛的事情)如何实现这一点。
以下说明假设您知道如何使用 RegisterShellHookWindow。
在将接收 shell 挂钩的窗口过程中,查找 HSHELL_GETMINRECT。
现在,从现在开始我遇到了问题。根据 MSDN,传递的 lparam 成员包含一个指向“SHELLHOOK”对象的指针。这是事实,但是,我无法让它工作,因为这个结构的“rc”成员是一个 RECT,与 Windows 头文件中的实际 RECT 结构不同。头文件中的 RECT 使用 LONG 作为其成员,就像这里一样,我们想要 SHORT。
无论如何,这是我如何完成此任务的一个片段。
要定义的结构:
然后在窗口过程上:
当最小化应用程序中的程序时,我遇到了一些动画默认返回原始动画的情况。我通过最小化它们解决了这个问题,如下所示:
如果您想了解有关我的项目的更多信息,或者您只是想查看源代码,请随时访问 https://github.com/Fafson/OpenMMT
I am working on an open source multi-monitor taskbar project called "OpenMMT." I've recently discovered (through many headaches) how to accomplish this.
The following explanation assumes that you know how to go about using RegisterShellHookWindow.
On the window procedure that will receive the shell hooks, look for HSHELL_GETMINRECT.
Now, from here on out is where I had problems. According to MSDN, the lparam member passed contains a pointer to a "SHELLHOOK" object. Which is true, however, I could not get it to work for the simple fact that the "rc" member of that structure, is a RECT that differs from the actual RECT structure in the Windows header files. The RECT in the header files uses LONG for its members, were as on here, we want SHORT.
Anyways, here's a snippet on how I accomplished this.
Structures to define:
Then on the Window Procedure:
When minimizing programs from my application I encountered some instances where the animation would default back to the original one. I resolved this by minimizing them like so:
If you want more info regarding my project or you just want to peek at the source, feel free to do so at https://github.com/Fafson/OpenMMT
ptMinPosition 成员>
WINDOWPLACEMENT
结构指定窗口最小化时的坐标,因此SetWindowPlacement
函数可用于达到此效果。但一些测试显示窗口不应该有任务栏按钮才能工作(即没有WS_EX_APPWINDOW
)。我不知道 RocketDock 是如何工作的,但我想这可以通过安装全局
WH_CBT
挂钩,并根据HCBT_MINMAX
通知采取行动(设置 ex_style,然后设置最小化坐标)。The
ptMinPosition
member of theWINDOWPLACEMENT
structure specifies the coordinates of the window when it is minimized, soSetWindowPlacement
function can be used to that effect. But some testing shows the window should not have a task bar button for that to work (i.e. noWS_EX_APPWINDOW
).I don't know how RocketDock works, but I guess this could be achieved by installing a global
WH_CBT
hook, and acting upon (setting the ex_style and then setting minimized coordinates)HCBT_MINMAX
notification.您可以使用 AnimateWindow API 函数,并传递它,例如 AW_HOR_POSITIVE | AW_VER_POSITIVE 获取对角线动画。
我将从捕获 WM_SYSCOMMAND/SC_MINIMIZE 的全局钩子开始,并使用 AnimateWindow 来定位右上角。
如果这不能提供所需的效果,下一步将使用 WM_PRINT/WM_PRINTCLIENT 将窗口的副本获取到位图中(我相信这是 AnimateWindow 内部所做的),然后隐藏窗口并执行我自己的动画。
You can use the AnimateWindow API function, and pass it e.g. AW_HOR_POSITIVE | AW_VER_POSITIVE to get a diagonal animation.
I'd start with a global hook catching WM_SYSCOMMAND/SC_MINIMIZE, and use AnimateWindow to target the top right corner.
If this doesn't provide the desired effect, the next step would be to use WM_PRINT/WM_PRINTCLIENT to get a copy of the window into a bitmap (I believe this is what AnimateWindow does internally), then hiding the window and doing my own animation.