Implementation of floating windows on the desktop (similar to malicious advertisements)

Source: Internet
Author: User

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 .~

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.