基本信息
源码名称:动态移动图片
源码大小:0.08M
文件格式:.zip
开发语言:C#
更新时间:2021-01-04
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍
根据鼠标光标位置动态移动生成的图标

private void PictureBox_MouseDown(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
isDrag = true;
//重新设置rect的位置,跟随鼠标移动 
rect.Location = getPointToForm(new Point(e.Location.X - mouseDownPoint.X, e.Location.Y - mouseDownPoint.Y), sender);
this.Refresh();
}
}

private void PictureBox_MouseMove(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
isDrag = true;
//重新设置rect的位置,跟随鼠标移动 
rect.Location = getPointToForm(new Point(e.Location.X - mouseDownPoint.X, e.Location.Y - mouseDownPoint.Y), sender);
this.Refresh();
}
}
private void PictureBox_MouseUp(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
if (isDrag) {
isDrag = false;
//移动control到放开鼠标的地方 
actX = rect.Location.X - (picWidth / 2);
actY = rect.Location.Y - (picHeight / 2);
(sender as PictureBox).Location = new Point(rect.Location.X - (picWidth / 2), rect.Location.Y - (picHeight / 2));
this.Refresh();
deviceInfo.x = actX;
deviceInfo.y = actY;
}
reset();
}
}