Dim?xx?As?Double,?yy?As?Double
Private?Sub?Form_MouseMove(Button?As?Integer,?Shift?As?Integer,?X?As?Single,?Y?As?Single)
If?xx?=?0?And?yy?=?0?Then
xx?=?X:?yy?=?Y
Else
Form1.Line?(xx,?yy)-(X,?Y),?1
End?If
End?Sub
我调试成功的例子.
①在mouse事件中实现
实现方式为:
[csharp] view plain copy
Point mouseOff;//鼠标移动位置变量
bool leftFlag;//标签是否为左键
private void groupControl1_MouseUp(object sender, MouseEventArgs e)
{
if (leftFlag)
leftFlag = false;//释放鼠标后标注为false;
}
private void groupControl1_MouseMove(object sender, MouseEventArgs e)
Point mouseSet = Control.MousePosition;
mouseSet.Offset(mouseOff.X, mouseOff.Y); //设置移动后的位置
Location = mouseSet;
private void groupControl1_MouseDown(object sender, MouseEventArgs e)
if (e.Button == MouseButtons.Left)
mouseOff = new Point(-e.X, -e.Y); //得到变量的值
调用前需要添加using System.Runtime.InteropServices;
public static extern bool ReleaseCapture();
public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
ReleaseCapture(); //释放鼠标捕捉
Dim
s
As
Boolean,
ci
Integer,
xianxing
xiankuan
Integer
x0
Single,
y0
Single
Private
Sub
Command1_Click()
=
True
Command1.Enabled
False
End
Form_Load()
b
Array("透明",
"实线",
"虚线",
"点线",
"点划线",
"双点划线")
Frame1.Move
①.00,
Frame1.Caption
"线型"
Width
-
"线宽"
For
i
To
Option1(i).Move
+
*
①.100,
Option1(i).Caption
b(i)
"点宽"
Next
Shape1(0).Visible
Shape1(1).Visible
Command1.Caption
"开始画圆"
Command1.ToolTipText
Form_MouseDown(Button
Shift
X
Y
Single)
If
And
Button
Then
Load
Shape1(ci)
Shape1(ci).Visible
Shape1(ci).BorderStyle
Shape1(ci).Move
x0,
y0,
0,
Shape1(ci).Shape
Shape1(ci).BorderWidth
Form_MouseMove(Button
banjing
Sqr((x0
X)
(x0
(y0
Y)
Y))
banjing,
Form_MouseUp(Button
Option1_Click(Index
Integer)
Option1(i)
界面稍微复杂了点:
以上就是土嘎嘎小编为大家整理的vb.net鼠标拖动画相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!