奇码科技论坛 » 〖.NET〗 » [NET技术文章]窗体启动特效 转到动态网页
--> 本页主题: [NET技术文章]窗体启动特效 加为IE收藏 | 收藏主题 | 上一主题 | 下一主题
惢惢


级别: 管理员
精华: 3
发帖: 3831
经验: 29967 点
金钱: 17459 G币
贡献值: 0 点
好评度: 3 点
在线时间:0(小时)
注册时间:2006-07-21


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


顶端 Posted:2006-10-25 23:16 | [楼 主]

 奇码科技论坛 -> 〖.NET〗
快速发帖 顶端
内容
HTML 代码不可用

使用签名
Wind Code自动转换

字数检查 恢复数据
 认证码:  
按 Ctrl+Enter 直接提交
表情 [更多]

Powered by PHPWind v5.3 Code © 2003-07 PHPWind