首页 | 互联网 | IT动态 | IT培训 | Cisco | Windows | Linux | Java | .Net | Oracle | 软件测试 | C/C++ | 嵌入式开发 | 存储世界 | 服务器
网络设备 | IDC | 安全 | 求职招聘 | 数字网校 | 笔记本电脑 | 北大青鸟 | 技术专题 | 电子书下载 | 教学视频 | 源码下载 | 搜索 | 博客 | 论坛
中国IT实验室Dotnet频道
中国IT教育
Google
首页 ASP.NET  C#  XML/WebService ADO.NET VC.NET VB.NET .NET 资讯动态 专题 RSS订阅 讨论 下载
您现在的位置: 中国IT实验室 >> Dotnet >> ASP.NET >> 正文

窗体启动特效

【思路】:

在Form的OnLoad中 先使Form不可见,然后从内向外,一层一层绘制Rectangle ,最后让Form可见

【难点】

首先输出效果的Rectangle要有个地方显示,Main Form可不行,因为当绘制Rectangle的时候 ,Form是不可见的,这里使用了Desktop桌面

【代码如下】

1. 加入命名空间

using System.Drawing.Imaging;

using System.Runtime.InteropServices;

2. 声明Win32 Api GetDC()

[ DllImport("user32") ]

public static extern System.IntPtr GetDC(System.IntPtr dc);

3. 声明变量

System.Drawing.Graphics g; //画图板

Pen p=new Pen(Color.Black,1); //画笔

int startx,starty,wx,wy,step; //startx,starty,wx,wy确定一个矩形

int cx,cy; //cx,cy为form的client的width 和height

4.在Form的OnLoad上加上如下代码

this.Visible=false;

step=1;

g=Graphics.FromHdc(GetDC(System.IntPtr.Zero));

cx=this.ClientSize.Width;

cy=this.ClientSize.Height;

this.Visible=false;

step=1;

while(step<=cx/2)

{

startx=cx/2-step;

starty=cy*startx/cx;

wx=2*step;

wy=wx*cy/cx;

startx+=this.Left;

starty+=this.Top+this.Height-this.ClientSize.Height;

g.DrawRectangle(p,startx,starty,wx,wy);

System.Threading.Thread.Sleep(100);

step+=10;

}

this.Visible=true;

【责编:Peng】

中国IT教育

相关产品和培训
文章评论
 友情推荐链接
 认证培训
 专题推荐

 ·算法分析与设计之五大常用算法
 ·开发必备 漫谈Java加密保护
 ·嵌入式开发--ARM技术专题
 ·C/C++指针,认真了解,灵活运用
 ·.NET开发:C#实用基础教程
 ·软件测试工具QTP学习专题
 ·嵌入式开发单片机解决方案专题
 ·Java开发环境 Greenfoot 程序员手册
 ·C++对象布局及多态实现的探索
 ·常见排序算法的实现
 今日更新
 社区讨论
 博客论点
 频道精选
 Dotnet频道相关导航