using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace floatingForm
{
public partial class FloatingForm : Form
{
public FloatingForm()
{
InitializeComponent();
} private void timer1_Tick(object sender, EventArgs e)
{
Point p = new Point(0,370);
//p.X = this .DesktopLocation .X ;
while (this .DesktopLocation .X <=0)
{
for (int i = 0; i < this.DesktopBounds.Width; i++)
{
Point p1 = new Point(this.DesktopLocation.X + 1, this.DesktopLocation.Y);
this.DesktopLocation = p1;
//p = p1;
}
if (this.DesktopLocation.X == this.DesktopBounds.Width)
{
for (int i = this.DesktopBounds.Width; i > 0; i++)
{
//Point p2 = new Point(20, 370);
//this.DesktopLocation = p2; Point p2 = new Point(this.DesktopLocation.X - 1, this.DesktopLocation.Y); this.DesktopLocation = p2;
}
} this.DesktopLocation = p; }
} private void FloatingForm_Load(object sender, EventArgs e)
{
Point p = new Point(0, 370);
this.DesktopLocation = p;
}
}
}
在程序运行时,只能够来回一次,我想做的是能够不断自动来回的,想了好半天还是没头绪,小弟我是初学者,希望有哪位大大能够帮忙解答一下,非常感谢!!!
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace floatingForm
{
public partial class FloatingForm : Form
{
public FloatingForm()
{
InitializeComponent();
} private void timer1_Tick(object sender, EventArgs e)
{
Point p = new Point(0,370);
//p.X = this .DesktopLocation .X ;
while (this .DesktopLocation .X <=0)
{
for (int i = 0; i < this.DesktopBounds.Width; i++)
{
Point p1 = new Point(this.DesktopLocation.X + 1, this.DesktopLocation.Y);
this.DesktopLocation = p1;
//p = p1;
}
if (this.DesktopLocation.X == this.DesktopBounds.Width)
{
for (int i = this.DesktopBounds.Width; i > 0; i++)
{
//Point p2 = new Point(20, 370);
//this.DesktopLocation = p2; Point p2 = new Point(this.DesktopLocation.X - 1, this.DesktopLocation.Y); this.DesktopLocation = p2;
}
} this.DesktopLocation = p; }
} private void FloatingForm_Load(object sender, EventArgs e)
{
Point p = new Point(0, 370);
this.DesktopLocation = p;
}
}
}
在程序运行时,只能够来回一次,我想做的是能够不断自动来回的,想了好半天还是没头绪,小弟我是初学者,希望有哪位大大能够帮忙解答一下,非常感谢!!!
解决方案 »
- 关于定时器的问题请教各位
- 如何在保存对话框中默认文件类型
- 如何将XmlDocument转化为System.IO.Stream
- ArrayList.Toarray(System.Type type)
- 如何绘制立体的边框?兄弟姐妹们,出手了!
- WPF_Listview中的一个让人哭笑不得的BUG.
- c#求局域网内Sql server 服务器名,谢谢
- 请问这个2个正则表达式是什么意思 谢谢
- 怎么样保存dataset中的修改过的值 不让页面重载时把dataset重新初始化?
- 下面代码里面用SqlDateTime赋值的那两句总是出错,不知道为什么,请高手指点!!!
- 请问在多用户环境下如何处理对Access数据库同时对同一条记录进行修改???
- mapinfo引用问题 GPS软件 急..........高手务必进~!
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);
}
}
}