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. 自定义DTD(myeclipser的XML提示功能)

    了解DTD定义详见:http://www.w3school.com.cn/dtd/dtd_elements.asp PS:文本只是简单的介绍,启到抛砖引玉的作用. 1.创建DTD文件 <?xml ...

  2. 【转】彻底解决INSTALL_FAILED_UPDATE_INCOMPATIBLE的安装错误

    原文网址:http://bbs.9ria.com/thread-245162-1-1.html 利用adb shell进入系统,进入/data/app或者/data/data,删除跟你安装的apk同样 ...

  3. TortoiseGit 使用教程

    原文地址:http://blog.csdn.net/ethan_xue/article/details/7749639 git的使用越来越广泛 使用命令比较麻烦,下面讲解一下tortoisegit的使 ...

  4. (Stack)Basic Calculator I && II

    Basic Calculator I Implement a basic calculator to evaluate a simple expression string. The expressi ...

  5. poj1014:母函数+优化

    题目大意: 有1~6六种宝石,价格分别为1~6 ..给定每种宝石的个数,问能否平分给两个人 分析: 一看显然是个多重背包问题,也可以用母函数做 不过母函数的复杂度是n*v*k,第一次tle了.. 后来 ...

  6. java实现矩阵连乘的动态规划

    package com.cjs.algorithm; public class DynamicPlan { /** * 此方法用来求解矩阵连乘的最小数乘次数 * * @param p * 传入的要连乘 ...

  7. first move advantage_百度搜索

    first move advantage_百度搜索 先动优势

  8. hibernate分页查询的各种方法

    统计总数: public Integer countAll1() { String hql = "select count(*) from News as news"; List ...

  9. 转:Excel转换XML工具<一>

    http://blog.csdn.net/candle806/article/details/7441695最近在整理测试用例,所以想找一个合适的工具来完成对测试需求.测试用例的管理.对比了一翻,发现 ...

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

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