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鼠标操作
分享网址:https://www.cdcxhl.com/article18/ddedggp.html

成都网站建设公司_创新互联,为您提供网页设计公司品牌网站设计动态网站面包屑导航定制开发网站营销

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都做网站