欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

桌面浮動窗口(類似惡意廣告)的實現(xiàn)詳解

 更新時間:2013年06月08日 15:06:38   作者:  
本篇文章是對桌面浮動窗口的實現(xiàn)方法進行了詳細的分析介紹,需要的朋友參考下
突然想起來flash有碰撞反彈飄動as控制的效果,所以想起來用c#也來做一個桌面飄動碰撞反彈無標題欄窗體。有點像中了惡意病毒廣告效果。
主要代碼如下(使用了一timer控件和一Button(為了我自己控制),窗體的BorderStyle設置為None):
復制代碼 代碼如下:

        int ScreenWidth = SystemInformation.PrimaryMonitorMaximizedWindowSize.Width;
        int ScreenHeight = SystemInformation.PrimaryMonitorMaximizedWindowSize.Height;
        private int speedX = 4;
        private int speedY = 3;
        private bool canMove = true;
        int myswitch = 1;//為了我可以控制停止所以添加的飄與停的切換開關
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (canMove)
            {
                this.DesktopLocation = new Point(this.DesktopLocation.X + speedX, this.DesktopLocation.Y + speedY);
                if (this.DesktopLocation.X + this.Width >= ScreenWidth || this.DesktopLocation.X < 0)
                {
                    speedX = -speedX;
                }
                if (this.DesktopLocation.Y + this.Height >= ScreenHeight || this.DesktopLocation.Y < 0)
                {
                    speedY = -speedY;
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            myswitch *= -1;
            if (myswitch == -1)
            {
                canMove = false;
                //button1.Text = "飄動";
            }
            else
            {
                canMove = true;
                //button1.Text = "停止";
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
        }
        private void Form1_DoubleClick(object sender, EventArgs e)
        {
            Application.Exit();
        }

暫寫這么多,有時間把它再增強下更像惡意廣告。~

相關文章

最新評論