SoFunction
Updated on 2025-03-07

Detailed explanation of the implementation of desktop floating window (similar to malicious advertising)


        int ScreenWidth = ;
        int ScreenHeight = ;
        private int speedX = 4;
        private int speedY = 3;
        private bool canMove = true;
int myswitch = 1;//In order for me to control the stop, the flutter and stop switch added
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (canMove)
            {
                = new Point( + speedX, + speedY);
                if ( + >= ScreenWidth || < 0)
                {
                    speedX = -speedX;
                }
                if ( + >= ScreenHeight || < 0)
                {
                    speedY = -speedY;
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            myswitch *= -1;
            if (myswitch == -1)
            {
                canMove = false;
// = "Floating";
            }
            else
            {
                canMove = true;
// = "Stop";
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
        }
        private void Form1_DoubleClick(object sender, EventArgs e)
        {
            ();
        }