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 [..] of Int64;
begin
if DispMode= then begin
//显示
Flag[]:=AW_ACTIVATE+AW_HOR_POSITIVE+AW_VER_POSITIVE+AW_SLIDE;//左上至右下 滑行效果
Flag[]:=AW_ACTIVATE+AW_HOR_NEGATIVE+AW_VER_POSITIVE+AW_SLIDE;//右上至左下 滑行效果
Flag[]:=AW_ACTIVATE+AW_CENTER+AW_SLIDE; // 中心向四周 滑行效果
Flag[]:=AW_ACTIVATE+AW_HOR_POSITIVE+AW_SLIDE; //左 至右 滑行效果
Flag[]:=AW_ACTIVATE+AW_HOR_NEGATIVE+AW_SLIDE; //右至左 滑行效果
Flag[]:=AW_ACTIVATE+AW_VER_POSITIVE+AW_SLIDE; //上至下 滑行效果
Flag[]:=AW_ACTIVATE+AW_HOR_POSITIVE+AW_VER_POSITIVE+AW_BLEND;//左上至右下 淡入淡出
Flag[]:=AW_ACTIVATE+AW_HOR_NEGATIVE+AW_VER_POSITIVE+AW_BLEND;//右上至左下 淡入淡出
Flag[]:=AW_ACTIVATE+AW_HOR_POSITIVE+AW_BLEND; //左至右 淡入淡出
Flag[]:=AW_ACTIVATE+AW_HOR_NEGATIVE+AW_BLEND; //右至左 淡入淡出
Flag[]:=AW_ACTIVATE+AW_VER_POSITIVE+AW_BLEND; //上至下 淡入淡出
Flag[]:=AW_ACTIVATE+AW_CENTER+AW_BLEND; //中心向四周 淡入淡出
end;
if DispMode= then begin
//关闭
Flag[]:=AW_HIDE+AW_HOR_POSITIVE+AW_VER_NEGATIVE+AW_SLIDE;//左上至右下 滑行效果
Flag[]:=AW_HIDE+AW_HOR_NEGATIVE+AW_VER_NEGATIVE+AW_SLIDE;//右上至左下 滑行效果
Flag[]:=AW_HIDE+AW_CENTER+AW_SLIDE; // 中心向四周 滑行效果
Flag[]:=AW_HIDE+AW_HOR_POSITIVE+AW_SLIDE; //左 至右 滑行效果
Flag[]:=AW_HIDE+AW_HOR_NEGATIVE+AW_SLIDE; //右至左 滑行效果
Flag[]:=AW_HIDE+AW_VER_NEGATIVE+AW_SLIDE; //上至下 滑行效果
Flag[]:=AW_HIDE+AW_HOR_POSITIVE+AW_VER_NEGATIVE+AW_BLEND;//左上至右下 淡入淡出
Flag[]:=AW_HIDE+AW_HOR_NEGATIVE+AW_VER_NEGATIVE+AW_BLEND;//右上至左下 淡入淡出
Flag[]:=AW_HIDE+AW_HOR_POSITIVE+AW_BLEND; //左至右 淡入淡出
Flag[]:=AW_HIDE+AW_HOR_NEGATIVE+AW_BLEND; //右至左 淡入淡出
Flag[]:=AW_HIDE+AW_VER_POSITIVE+AW_BLEND; //上至下 淡入淡出
Flag[]:=AW_HIDE+AW_CENTER+AW_BLEND; //中心向四周 淡入淡出
end;
Randomize;
Result := AnimateWindow(WHandle,,Flag[Random()]);
end; { TForm2 } procedure TForm2.close;
begin
// if AnimateWindow( Handle,200,AW_VER_POSITIVE+AW_HIDE)=false then
if ShowWindows(Handle,)=false then
begin
showmessage('窗体退出出错');
free;
end;
inherited close;
end; procedure TForm2.Show;
begin
top:=;
left:=;
// if AnimateWindow(Handle,200,AW_VER_NEGATIVE)=false then
if ShowWindows(Handle,)=false then
begin
showmessage('窗体显示出错');
free;
end;
inherited show;
end; end.

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

AnimateWindow的更多相关文章

  1. C#.NET使用AnimateWindow制作淡入淡出特殊效果的窗体

    使用AnimateWindow制作淡入淡出效果的窗体 命名空间: using System.Runtime.InteropServices; API函数: [DllImport("user3 ...

  2. AnimateWindow 阻塞当前线程问题

    今天查了蛮多的,虽然不是系统的学习,收获也不小.下面说一下我的解决方法: 问题一:采用 AnimateWindow API实现消息窗体FormMsg的动画出现,但由于该方法会阻塞当前线程,造成其他窗体 ...

  3. Delphi使用Windows API函数AnimateWindow实现窗体特效

    {**********************************************************************API函数 AnimateWindow 使用:函数功能:窗 ...

  4. 调用AnimateWindow API来实现弹出效果

    下面是实例的cs代码 public partial class frm_Main : Form { //使用Windows Api AnimateWindow [DllImport("use ...

  5. AnimateWindow类

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  6. 使用AnimateWindow来实现窗口淡入淡出(主要有四种动画,滚动,滑动,折叠或展开,和淡入淡出)

    如果是在VC6下进行编译,应引入下面的预编译宏,注意放在windows.h的前面#undef  WINVER   #define  WINVER   0x500为什么要引入上面的宏呢?看看winuse ...

  7. 【C#】组件发布:MessageTip,轻快型消息提示窗

    -------------201610212046更新------------- 更新至2.0版,基本完全重写,重点: 改为基于原生LayeredWindow窗体和UpdateLayeredWindo ...

  8. 转:Delphi 6 实用函数

    来自: daocaoren0824, 时间: -- ::, ID: 再给你一份 程序员实用函数 {▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎▎} {▎ ▎} {▎ 大 ...

  9. winform下如何实现右下角弹窗效果

    [DllImport("user32")] private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, in ...

随机推荐

  1. RedisTemplate

    Spring Boot中Jedis几个api返回值的确认 @RequestMapping("/del/{key}") public String del(@PathVariable ...

  2. GSM Channel Mode Modify和Channel Mode Modify Acknowledge信令

    最近研究了下如何通过GSM Channel Mode Modify和Channel Mode Modify Acknowledge信令,获知GSM终端支持的data Rate   思路与原理: • I ...

  3. C# 使用Sqlite 如何返回统计行数

    Visual 2010 with Sqlite 需要这样Query 数据: select count(*) from tblOrder where OrderStartTime >= '2013 ...

  4. fcntl函数加文件锁

    对文件加锁是原子性的,可以用于进程间文件操作的同步.在linux下,有三个函数可以对文件进程加锁,分别是fcntl.flock.lockf.这里只说fcntl,它的用法也是最复杂的. fcntl是fi ...

  5. js获取url传递参数(转的,原作不详)

    这里是一个获取URL带QUESTRING参数的JAVASCRIPT客户端解决方案,相当于asp的request.querystring,PHP的$_GET 函数: <Script languag ...

  6. git 拆库 切库 切分 子目录建库

    如果git库目录是这样的: git根目录 project_a/ project_b/ ... 并且想为project_a单独创建一个代码库 # 拉一个新分支 git co -b project_a_r ...

  7. StretchDIBits使用方法

    转自:http://blog.csdn.net/giantchen547792075/article/details/6996011 StretchDIBits 函数把DIB.JPEG.PNG图像中一 ...

  8. [Javascript] Regex: '$`', '$&', '$''

    var input = "foobar"; var result = input.replace('bar', '$`'); // $`: replace 'bar' with e ...

  9. [Cycle.js] Main function and effects functions

    We need to give structure to our application with logic and effects. This lessons shows how we can o ...

  10. F# 天生就是就异步和并行的料

    做模型开发免不了要使用异步和并行计算,尤其在多核CPU的今天,更是如此,F#恰逢其时,天生就具备这种能力,先看一个例子. open System open System.Drawing open Sy ...