窗体启动特效

分类: asp.net   出处:iocblog整理  更新时间:2009-01-10   添加到收藏  

【思路】:

在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;[www.iocblog.net 来源]

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;


Tag: 窗体启动 ,特效



文章整理:iocblog
版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。