用于重定向最小化动画的 Win32 C API

发布于 2024-10-17 13:04:07 字数 141 浏览 11 评论 0 原文

我见过 RocketDock 在 Vista 中重定向最小化动画,因此窗口最小化到 Dock,我只是好奇这是如何完成的。实际的最小化动画是重定向到 Dock,还是像一个钩子一样阻止 Windows 最小化窗口,而 RocketDock 在窗口最小化时有一个自定义动画?

I have seen RocketDock redirect the minimize animation in Vista so windows minimize to the dock, and am just curious how this was done. Is the actual minimize animation redirected to the dock, or is something like a hook to stop Windows from minimizing the window and RocketDock has a custom animation when the window is minimized?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

喜你已久 2024-10-24 13:04:07

我正在开发一个名为“OpenMMT”的开源多显示器任务栏项目。我最近发现(通过许多令人头痛的事情)如何实现这一点。

以下说明假设您知道如何使用 RegisterShellHookWindow。

在将接收 shell 挂钩的窗口过程中,查找 HSHELL_GETMINRECT。

现在,从现在开始我遇到了问题。根据 MSDN,传递的 lparam 成员包含一个指向“SHELLHOOK”对象的指针。这是事实,但是,我无法让它工作,因为这个结构的“rc”成员是一个 RECT,与 Windows 头文件中的实际 RECT 结构不同。头文件中的 RECT 使用 LONG 作为其成员,就像这里一样,我们想要 SHORT。

无论如何,这是我如何完成此任务的一个片段。

要定义的结构:

typedef struct {
  SHORT left;
  SHORT top;
  SHORT right;
  SHORT bottom;
} REALRECT, *LPREALRECT;

typedef struct {
  HWND hWnd; 
  REALRECT rc;
} DOCUMENT_ME_RIGHT_MICROSOFT, *LPDOCUMENT_ME_RIGHT_MICROSOFT;

然后在窗口过程上:

case HSHELL_GETMINRECT:
{
  LPDOCUMENT_ME_RIGHT_MICROSOFT lpShellHook = (LPDOCUMENT_ME_RIGHT_MICROSOFT)lParam;
  // lpShellHook now contains all the info. If you want to change the location
  // of the animation, simply change the lpShellHook->rc members to point
  // to the right coordinates and then return TRUE;
  return TRUE;
}

当最小化应用程序中的程序时,我遇到了一些动画默认返回原始动画的情况。我通过最小化它们解决了这个问题,如下所示:

void MinimizeApp(HWND hWnd) {
  SetForegroundWindow(hWnd);
  ShowWindowAsync(hWnd, SW_MINIMIZE);
}

如果您想了解有关我的项目的更多信息,或者您只是想查看源代码,请随时访问 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:

typedef struct {
  SHORT left;
  SHORT top;
  SHORT right;
  SHORT bottom;
} REALRECT, *LPREALRECT;

typedef struct {
  HWND hWnd; 
  REALRECT rc;
} DOCUMENT_ME_RIGHT_MICROSOFT, *LPDOCUMENT_ME_RIGHT_MICROSOFT;

Then on the Window Procedure:

case HSHELL_GETMINRECT:
{
  LPDOCUMENT_ME_RIGHT_MICROSOFT lpShellHook = (LPDOCUMENT_ME_RIGHT_MICROSOFT)lParam;
  // lpShellHook now contains all the info. If you want to change the location
  // of the animation, simply change the lpShellHook->rc members to point
  // to the right coordinates and then return TRUE;
  return TRUE;
}

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:

void MinimizeApp(HWND hWnd) {
  SetForegroundWindow(hWnd);
  ShowWindowAsync(hWnd, SW_MINIMIZE);
}

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

撑一把青伞 2024-10-24 13:04:07

ptMinPosition 成员>WINDOWPLACEMENT 结构指定窗口最小化时的坐标,因此SetWindowPlacement 函数可用于达到此效果。但一些测试显示窗口不应该有任务栏按钮才能工作(即没有 WS_EX_APPWINDOW)。

我不知道 RocketDock 是如何工作的,但我想这可以通过安装全局 WH_CBT 挂钩,并根据 HCBT_MINMAX 通知采取行动(设置 ex_style,然后设置最小化坐标)。

The ptMinPosition member of the WINDOWPLACEMENT structure specifies the coordinates of the window when it is minimized, so SetWindowPlacement 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. no WS_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.

櫻之舞 2024-10-24 13:04:07

您可以使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文