Windows下有一个函数AnimateWindow,在Delphi自带的Win32 API Help中是找不到的.你可以在Delphi的编辑器中输入windows.等待代码向导出来,继续输入AnimateWindow就能看到确实是存在的Win32 API,它的功能是在显示或者关闭窗体的时候产生动画,如从左向右开屏,从中心向周围开屏等. 语法:function AnimateWindow(hWnd: HWND; dwTime: DWORD; dwFlags: DWORD): BOOL; stdcall; 参数:hWnd : 想要显示动画窗体的句柄 dwTime : 动画时间数,单位毫秒 dwFlags : 显示方式,取值如下定义 1.AW_HOR_POSITIVE = $00000001; // 从左向右开屏 2.AW_HOR_NEGATIVE = $00000002; // 从右向左开屏 3.AW_VER_POSITIVE = $00000004; // 从上向下开屏 4.AW_VER_NEGATIVE = $00000008; // 从下向上开屏 5,AW_CENTER = $00000010; // 从中心向四周扩展,在关闭动画中则为从四周向中心收缩 6.AW_HIDE = $00010000; // 关闭时候与前面的定义组合使用,如AW_HIDE or AW_CENTER 7.AW_ACTIVATE = $00020000; // 与1-5组合,开屏使用 8.AW_SLIDE = $00040000; // 与1-5 + 6/7 组合,产生滑行效果 9.AW_BLEND = $00080000; // Win2000下使用,淡入淡出效果 例子: unit Unit1;
interface
uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls;
type TForm1 = class(TForm) procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin AnimateWindow(handle,200,AW_HIDE+AW_CENTER); end;
procedure TForm1.FormCreate(Sender: TObject); begin AnimateWindow(handle,200,AW_CENTER); end;
end.
|