作为多屏视频监控
要实现:
10x10的方格,(用什么控件没有限制)显示一百个画面,用户用鼠标拖动可以把鼠标覆盖的格子单独输出。
比如能任意拖拽出3x4, 5x6的画面。
只需实现这个拖拽功能就行,求各位大神指点下 本人小白。
用C#设计窗口程序,实现鼠标能随意拖拽
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答
- 过客1996 2018-04-17 02:19关注
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Runtime.InteropServices;namespace WindowsApplication1
{public partial class Form1 : Form { Point pt; bool moves = true; public Form1() { InitializeComponent(); }
private void button1_Click(object sender, EventArgs e)
{
if (moves == true)
{
MessageBox.Show("sfdfdf");
}
}private void button1_MouseDown(object sender, MouseEventArgs e) { pt = Cursor.Position; } private void button1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { int px = Cursor.Position.X - pt.X; int py = Cursor.Position.Y - pt.Y; button1.Location = new Point(button1.Location.X + px, button1.Location.Y + py); pt = Cursor.Position; moves = false; } } private void button1_MouseUp(object sender, MouseEventArgs e) { moves = true; } }
}
解决 无用评论 打赏 举报