Suddenly remembered that flash has the effect of collision and rebound as control, so I thought of using c # To make a desktop floating collision and rebound without a title bar form. It is a bit like a malicious virus advertisement.
The main code is as follows (a timer control and a Button are used (for my own control), and The BorderStyle of the form is set to None ):
Copy codeThe Code is as follows: 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; // The float and stop switch is added to control the stop for me.
Private void timereffectick (object sender, EventArgs e)
{
If (canMove)
{
This. Specify toplocation = new Point (this. Specify toplocation. X + speedX, this. Specify toplocation. Y + speedY );
If (this. exceed toplocation. X + this. Width> = ScreenWidth | this. exceed toplocation. X <0)
{
SpeedX =-speedX;
}
If (this. exceed toplocation. Y + this. Height> = ScreenHeight | this. exceed toplocation. Y <0)
{
SpeedY =-speedY;
}
}
}
Private void button#click (object sender, EventArgs e)
{
Myswitch * =-1;
If (myswitch =-1)
{
CanMove = false;
// Button1.Text = "floating ";
}
Else
{
CanMove = true;
// Button1.Text = "stop ";
}
}
Private void Form1_Load (object sender, EventArgs e)
{
}
Private void Form1_DoubleClick (object sender, EventArgs e)
{
Application. Exit ();
}
For now, there is so much time to increase it to be more like a malicious advertisement .~