Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
759 views
in Technique[技术] by (71.8m points)

winapi - Win32 C API for redirecting minimize animation

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...