注册 | 登录 | 设为首页 | 加入收藏
您当前的位置:飞翔学院-IT中国 → IT资讯互联网 → 文章内容

窗体启动特效

作者:佚名 来源:不详 发布时间:2007-10-13 14:30: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;

查看本文来源


  • 打印文档
  • 推荐好友
  • 返回顶部
  • 增大字体
  • 减少字体

热点文章

关于本站 | 工作机会 | 合作网站 | 广告服务 | 市场合作| 联系我们 | 抽奖活动
版权所有: 武汉威俊科技有限公司 Copyright 2005-2007 www.ITCNW.COM All rights reserved