Win32 C API for redirecting minimize animation

后端 未结 3 534
我在风中等你
我在风中等你 2020-12-20 19:21

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 redi

3条回答
  •  甜味超标
    2020-12-20 19:42

    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

提交回复
热议问题