美化winfrom窗体

30 篇文章 0 订阅

  [System.Runtime.InteropServices.DllImport("user32")]

        private static extern bool AnimateWindow(IntPtr hwnd, int dwTime, int dwFlags);

        private const int AW_HOR_POSITIVE = 0x0001;//从左向右显示

        private const int AW_HOR_NEGATIVE = 0x0002;//从右向左显示

        private const int AW_VER_POSITIVE = 0x0004;//从上到下显示

        private const int AW_VER_NEGATIVE = 0x0008;//从下到上显示

        private const int AW_CENTER = 0x0010;//从中间向四周

        private const int AW_HIDE = 0x10000;

        private const int AW_ACTIVATE = 0x20000;//普通显示

        private const int AW_SLIDE = 0x40000;

        private const int AW_BLEND = 0x80000;//透明渐变显示

 

  void texiao()
        {
            int animatetype = 10;

            Random a = new Random();

            int dwFlags = (int)a.Next(animatetype);

            switch (dwFlags)
            {

                case 0://普通显示

                    AnimateWindow(Handle, 1000, AW_ACTIVATE);

                    break;

                case 1://从左向右显示

                    AnimateWindow(Handle, 1000, AW_HOR_POSITIVE);

                    break;

                case 2://从右向左显示

                    AnimateWindow(Handle, 1000, AW_HOR_NEGATIVE);

                    break;

                case 3://从上到下显示

                    AnimateWindow(Handle, 1000, AW_VER_POSITIVE);

                    break;

                case 4://从下到上显示

                    AnimateWindow(Handle, 1000, AW_VER_NEGATIVE);

                    break;

                case 5://透明渐变显示

                    AnimateWindow(Handle, 1000, AW_BLEND);

                    break;

                case 6://从中间向四周

                    AnimateWindow(Handle, 1000, AW_CENTER);

                    break;

                case 7://左上角伸展

                    AnimateWindow(Handle, 1000, AW_SLIDE | AW_HOR_POSITIVE | AW_VER_POSITIVE);

                    break;

                case 8://左下角伸展

                    AnimateWindow(Handle, 1000, AW_SLIDE | AW_HOR_POSITIVE | AW_VER_NEGATIVE);

                    break;

                case 9://右上角伸展

                    AnimateWindow(Handle, 1000, AW_SLIDE | AW_HOR_NEGATIVE | AW_VER_POSITIVE);

                    break;

                case 10://右下角伸展

                    AnimateWindow(Handle, 1000, AW_SLIDE | AW_HOR_NEGATIVE | AW_VER_NEGATIVE);

                    break;

            }
        }

    private void Form1_Load(object sender, EventArgs e)
        {
            texiao();}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值