码迷,mamicode.com
首页 > Windows程序 > 详细

AnimateWindow

时间:2015-10-27 22:00:32      阅读:285      评论:0      收藏:0      [点我收藏+]

标签:

WINDOWS提供了一个很有意思的函数:AnimateWindow。
之前我想实现像MSN,QQ这些收到邮件的时候动画方式,从地下升上来的显示一个窗口,感觉很麻烦,自己去写代码,效果很不理想,今天无意中发现了一个函数AnimateWindow,能很好的实现这个功能。并且网上找了一个例子:

// 主窗体:
unit Unit1;
 
interface
 
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
 
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
 
var
Form1: TForm1;
 
implementation

// 动画显示窗体:
uses Unit2;
 
var
mesfrm:tform2;
 
{$R *.dfm}
 
procedure TForm1.Button1Click(Sender: TObject);
begin
mesfrm:=tform2.Create(application);
mesfrm.Show;
end;
 
procedure TForm1.Button2Click(Sender: TObject);
begin
mesfrm.close;
end;
 
end.

unit Unit2;
 
interface
 
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
 
type
TForm2 = class(TForm)
private
{ Private declarations }
public
{ Public declarations }
procedure Show;
procedure close;
end;
 
var
Form2: TForm2;
 
implementation
 
{$R *.dfm}
 
function ShowWindows(WHandle:HWND;DispMode:Integer): Boolean;
var Flag:array [0..11] of Int64;
begin
if DispMode=1 then begin
//显示
Flag[0]:=AW_ACTIVATE+AW_HOR_POSITIVE+AW_VER_POSITIVE+AW_SLIDE;//左上至右下 滑行效果
Flag[1]:=AW_ACTIVATE+AW_HOR_NEGATIVE+AW_VER_POSITIVE+AW_SLIDE;//右上至左下 滑行效果
Flag[2]:=AW_ACTIVATE+AW_CENTER+AW_SLIDE; // 中心向四周 滑行效果
Flag[3]:=AW_ACTIVATE+AW_HOR_POSITIVE+AW_SLIDE; //左 至右 滑行效果
Flag[4]:=AW_ACTIVATE+AW_HOR_NEGATIVE+AW_SLIDE; //右至左 滑行效果
Flag[5]:=AW_ACTIVATE+AW_VER_POSITIVE+AW_SLIDE; //上至下 滑行效果
Flag[6]:=AW_ACTIVATE+AW_HOR_POSITIVE+AW_VER_POSITIVE+AW_BLEND;//左上至右下 淡入淡出
Flag[7]:=AW_ACTIVATE+AW_HOR_NEGATIVE+AW_VER_POSITIVE+AW_BLEND;//右上至左下 淡入淡出
Flag[8]:=AW_ACTIVATE+AW_HOR_POSITIVE+AW_BLEND; //左至右 淡入淡出
Flag[9]:=AW_ACTIVATE+AW_HOR_NEGATIVE+AW_BLEND; //右至左 淡入淡出
Flag[10]:=AW_ACTIVATE+AW_VER_POSITIVE+AW_BLEND; //上至下 淡入淡出
Flag[11]:=AW_ACTIVATE+AW_CENTER+AW_BLEND; //中心向四周 淡入淡出
end;
if DispMode=2 then begin
//关闭
Flag[0]:=AW_HIDE+AW_HOR_POSITIVE+AW_VER_NEGATIVE+AW_SLIDE;//左上至右下 滑行效果
Flag[1]:=AW_HIDE+AW_HOR_NEGATIVE+AW_VER_NEGATIVE+AW_SLIDE;//右上至左下 滑行效果
Flag[2]:=AW_HIDE+AW_CENTER+AW_SLIDE; // 中心向四周 滑行效果
Flag[3]:=AW_HIDE+AW_HOR_POSITIVE+AW_SLIDE; //左 至右 滑行效果
Flag[4]:=AW_HIDE+AW_HOR_NEGATIVE+AW_SLIDE; //右至左 滑行效果
Flag[5]:=AW_HIDE+AW_VER_NEGATIVE+AW_SLIDE; //上至下 滑行效果
Flag[6]:=AW_HIDE+AW_HOR_POSITIVE+AW_VER_NEGATIVE+AW_BLEND;//左上至右下 淡入淡出
Flag[7]:=AW_HIDE+AW_HOR_NEGATIVE+AW_VER_NEGATIVE+AW_BLEND;//右上至左下 淡入淡出
Flag[8]:=AW_HIDE+AW_HOR_POSITIVE+AW_BLEND; //左至右 淡入淡出
Flag[9]:=AW_HIDE+AW_HOR_NEGATIVE+AW_BLEND; //右至左 淡入淡出
Flag[10]:=AW_HIDE+AW_VER_POSITIVE+AW_BLEND; //上至下 淡入淡出
Flag[11]:=AW_HIDE+AW_CENTER+AW_BLEND; //中心向四周 淡入淡出
end;
Randomize;
Result := AnimateWindow(WHandle,500,Flag[Random(6)]);
end;
 
{ TForm2 }
 
procedure TForm2.close;
begin
// if AnimateWindow( Handle,200,AW_VER_POSITIVE+AW_HIDE)=false then
if ShowWindows(Handle,2)=false then
begin
showmessage(窗体退出出错);
free;
end;
inherited close;
end;
 
procedure TForm2.Show;
begin
top:=430;
left:=560;
// if AnimateWindow(Handle,200,AW_VER_NEGATIVE)=false then
if ShowWindows(Handle,1)=false then
begin
showmessage(窗体显示出错);
free;
end;
inherited show;
end;
 
end.

http://www.cnblogs.com/barryhong/archive/2009/04/26/1443798.html

AnimateWindow

标签:

原文地址:http://www.cnblogs.com/findumars/p/4915509.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!