成都创新互联网站制作重庆分公司

vb点虐 鼠标长按 vbscript鼠标操作

VB点虐 怎样按住鼠标移动无边框窗体

1.在mouse事件中实现

创新互联公司专业IDC数据服务器托管提供商,专业提供成都服务器托管,服务器租用,服务器托管服务器托管,成都多线服务器托管等服务器托管服务。

2.调用windows API

实现方式为:

1.在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)

{

if (leftFlag)

{

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); //得到变量的值

leftFlag = true; //点击左键按下时标注为true;

}

}

private void groupControl1_MouseDown(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Left)

{

mouseOff = new Point(-e.X, -e.Y); //得到变量的值

leftFlag = true; //点击左键按下时标注为true;

}

}

2.调用windows API

调用前需要添加using System.Runtime.InteropServices;

[csharp] view plain copy

[DllImport("user32.dll")]

public static extern bool ReleaseCapture();

[DllImport("user32.dll")]

public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);

private void groupControl1_MouseDown(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Left)

{

ReleaseCapture(); //释放鼠标捕捉

//发送左键点击的消息至该窗体(标题栏)

SendMessage(Handle, 0xA1, 0x02, 0);

}

}

vb点虐 如何编写长按鼠标左键的事件?

SetCursorPos(old_x,old_y);

mouse_event(MOUSEEVENTF_LEFTDOWN,0,0,0,0);

SetCursorPos(pt_x,pt_y);

在VB.NET中如何实现键盘上两个键长按!在线等~~

长按你可以用计时器来实现啊,写个例子:

Private blCtrl As Boolean = False

Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown

If e.KeyCode = Keys.LControlKey Then blCtrl = True

End Sub

Private Sub Form1_KeyUp(sender As Object, e As KeyEventArgs) Handles Me.KeyUp

If e.KeyCode = Keys.LControlKey Then blCtrl = False

End Sub

然后你可以在计时器里检测blCtrl的状态来确定,不知道你的具体情况是什么样的

总之是用一个布尔变量来记录按键状态,配合计时器来达到你想要的功能

vb点虐 判断鼠标左键长按

很简单,加入全局变量中有一个变量,mousedown事件中设为1,在mouseup事件中置为0。这样就能实现你说的功能。

以下参考

Private Sub 天平左移按钮_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs) Handles 天平左移按钮.PreviewMouseDown

a=true

End Sub

Private Sub 天平左移按钮_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Input.MouseButtonEventArgs)Handles 天平左移按钮.PreviewMouseUp

a=false

End Sub


网站题目:vb点虐 鼠标长按 vbscript鼠标操作
本文URL:http://cxhlcq.com/article/ddedggp.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部