国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 編程 > C# > 正文

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

2020-01-24 03:14:10
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友
突然想起來(lái)flash有碰撞反彈飄動(dòng)as控制的效果,所以想起來(lái)用c#也來(lái)做一個(gè)桌面飄動(dòng)碰撞反彈無(wú)標(biāo)題欄窗體。有點(diǎn)像中了惡意病毒廣告效果。
主要代碼如下(使用了一timer控件和一Button(為了我自己控制),窗體的BorderStyle設(shè)置為None):
復(fù)制代碼 代碼如下:

        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;//為了我可以控制停止所以添加的飄與停的切換開關(guān)
        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 = "飄動(dòng)";
            }
            else
            {
                canMove = true;
                //button1.Text = "停止";
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
        }
        private void Form1_DoubleClick(object sender, EventArgs e)
        {
            Application.Exit();
        }

暫寫這么多,有時(shí)間把它再增強(qiáng)下更像惡意廣告。~
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 北票市| 阿拉尔市| 布尔津县| 呼玛县| 水富县| 赤城县| 张家界市| 合江县| 昌黎县| 甘南县| 农安县| 温州市| 正安县| 宁国市| 香河县| 黄大仙区| 麦盖提县| 安岳县| 大城县| 永胜县| 沙洋县| 双江| 肇庆市| 邵阳市| 辽阳县| 开平市| 桑植县| 怀柔区| 静安区| 来凤县| 华坪县| 亚东县| 松潘县| 油尖旺区| 河津市| 武强县| 平南县| 大新县| 巴中市| 潜江市| 漳平市|