110,533
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace FloatForm
{
public partial class Form1 : Form
{
int x;
int y;
int incre_x;
int incre_y;
public Form1()
{
InitializeComponent();
x = 0;
y = 370;
incre_x = 10;
incre_y = 10;
this.Location = new Point(x, y);
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
x += incre_x;
y += incre_y;
if (x > 1024 || x < 0)
incre_x *= -1;
if (y > 768 || y < 0)
incre_y *= -1;
this.Location = new Point(x, y);
}
}
}