手写代码实现窗体的拖动效果

手写代码实现窗体的拖动效果手写代码实现窗体的拖动效果代码

public partial class Form1 : Form
{
private Point oldPoint = new Point(0,0);
public Form1()
{
InitializeComponent();
}

private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
this.Close();
}

private void linkLabel2_MouseDown(object sender, MouseEventArgs e)
{
oldPoint.X
= Cursor.Position.X;
oldPoint.Y
= Cursor.Position.Y;
}

private void linkLabel2_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
int offset_x = Cursor.Position.X-oldPoint.X;
int offset_y = Cursor.Position.Y -oldPoint.Y;
this.Location = new Point(this.Location.X + offset_x, this.Location.Y + offset_y);
oldPoint.X
= Cursor.Position.X;
oldPoint.Y
= Cursor.Position.Y;
}
}
}

 

上一篇:《数字视频和高清:算法和接口》一第2章 图像的采样和显示


下一篇:FireFox IE Opera Safari 都可以正常播放WMV和MOV的网页播放器代码