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. 将某个Qt4项目升级到Qt5遇到的问题(13条方法)

    本文转载自http://hi.baidu.com/xchinux/item/9044d8ce986accbb0d0a7b87 一.将某个QT4项目改成QT5遇到的问题 该Qt4项目以前是使用Qt4.7 ...

  2. SSH转发机制

    第一部分 概述 当你在咖啡馆享受免费 WiFi 的时候,有没有想到可能有人正在窃取你的密码及隐私信息?当你发现实验室的防火墙阻止了你的网络应用端口,是不是有苦难言?来看看 SSH 的端口转发功能能给我 ...

  3. 股票市场问题(The Stock Market Problem)

    Question: Let us suppose we have an array whose ith element gives the price of a share on the day i. ...

  4. Android驱动之 Linux Input子系统之TP——A/B(Slot)协议

    将A/B协议这部分单独拿出来说一方面是因为这部分内容是比较容易忽视的,周围大多数用到input子系统的开发人员也不甚理解:另一方面是由于这部分知识一旦扩展到TP(触摸屏Touch Panel)的多点触 ...

  5. android面试题之六

    三十一.AIDL的全称是什么?如何工作?能处理哪些类型的数据? 英文全称:Android Interface Define Language(Android接口定义语言). 当A进程要去调用B进程中的 ...

  6. ext3中xtype属性汇总

    基本组件: xtype Class 描述 button Ext.Button 按钮 splitbutton Ext.SplitButton 带下拉菜单的按钮 cycle Ext.CycleButton ...

  7. javascript对URL中的参数进行简单加密处理

    javascript的api本来就支持Base64,因此我们可以很方便的来进行编码和解码. var encodeData = window.btoa("name=xiaoming&a ...

  8. 获取某个文件夹中所有txt文件

    <?php // 获取文件夹中的所有txt文件名 $dir = "D:/a"; //这里输入其他路径 $handle = opendir($dir."." ...

  9. [TypeScript] Avoid any type

    To avoid using "any" type is a best pratice. The reason for that is it disable the power o ...

  10. Difference between enabled and userInteractionEnabled properties

    I read through the documentation, and here are my findings. UIButton inherits from UIControl the boo ...