抄的:
unit TestForm;
interface
uses
Windows, Classes, Forms, Controls, StdCtrls, ExtCtrls;
type
TZoomAction = (zaMinimize, zaMaximize);
TfrmTest = class(TForm)
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
private
{ private declaration }
public
{ public declaration }
end;
var
frmTest: TfrmTest;
implementation
{$R *.DFM}
procedure ZoomEffect(theForm: TForm; theOperation: TZoomAction);
var
rcStart: TRect;
rcEnd: TRect;
rcTray: TRect;
hwndTray : hWnd;
hwndChild: hWnd;
begin
{ 寻找系统托盘区的位置}
hwndTray := FindWindow('Shell_TrayWnd', nil);
hwndChild := FindWindowEx(hwndTray, 0, 'TrayNotifyWnd', nil);
GetWindowRect(hwndChild, rcTray);
{点击用于最大化/最小化,并切换起始/结束}
if theOperation = zaMinimize then
begin
rcStart := theForm.BoundsRect;
rcEnd := rcTray;
end
else
begin
rcEnd := theForm.BoundsRect;
rcStart := rcTray;
end;
{ 以下是关键的部分... }
DrawAnimatedRects(theForm.Handle, IDANI_CAPTION, rcStart, rcEnd)
end;
procedure TfrmTest.FormClose(Sender: TObject; var Action: TCloseAction);
begin
ZoomEffect(Self, zaMinimize);
end;
procedure TfrmTest.FormShow(Sender: TObject);
begin
ZoomEffect(Self, zaMaximize);
end;
end.