新客网WWW.XKER.COM:致力做中国最专业的网络学院!
学院: 操作系统 - 网络应用 - 服务器 - 网络安全 - 工具软件 - 办公软件 - Web开发 - 数据库 - 网页设计 - 图形图像 - 媒体动画 - 硬件学堂 - 存储频道 - QQ专区
您的位置:首页 > 软件开发 > .Net开发 > Asp.net教程 > 正文:窗体启动特效

窗体启动特效

新客网 XKER.COM 2004-06-23 来源: 收藏本文
【效果图】


【思路】:

在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;



ps:这是第一次发表原创, 大家多多指教
收藏】 【评论】 【推荐】 【投稿】 【打印】 【关闭
发表评论
要记得去论坛讨论,点击注册新会员匿名评论
评论内容:不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
阅读排行
随机推荐
实用信息推荐