vb.net修改鼠标光标,vb鼠标光标形状

VB 改变桌面鼠标图标

不知道你是修改的是系统的还是程序的?

专注于为中小企业提供成都网站设计、成都网站建设服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业商都免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了上千企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

如果是程序的那就如上位所说 若想让关闭程序后鼠标仍改变那就参考下面

Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long

Declare Function SetSystemCursor Lib "user32" Alias "SetSystemCursor" (ByVal hCur As Long, ByVal id As Long) As Long

'关于 SetSystemCursor

hCur:光标的句柄,该函数hCur标识的光标的内容代替id定义的系统光标内容。系统通过调用DestroyCursor函数销毁hCur。因此hCur不能是由LoadCursor函数载入的光标。要指定一个从资源载入的光标,先用CopyCursor函数复制该光标,然后把该副本传送给SetSystemCursor函数。

id:指定由hour的内容替换系统光标。

下面是一系列的系统光标标识符:

OCR_APPSTARTING:标准箭头和小的沙漏

OCR_NORMAL:标准箭头

OCR_CROSS:交叉十字线光标

OCR_HAND:手的形状(Windows NT 5.0 和以后版本)

OCR_HELP:箭头和向东标记

OCR_IBEAM:I形梁

OCR_NO:斜的圆

OCR_SIZEALL:四个方位的箭头分别指向北、南、东、西

OCR_SIZENESEW:双箭头分别指向东北和西南

OCR_SIZENS:双箭头,分别指向北和南

OCR_SIZENWSE:双箭头分别指向西北和东南

OCR_SIZEWE:双箭头分别指向西和东

OCR_UP:垂直箭头

OCR_WAIT:沙漏

然后 SetSystemCursor LoadCursorFromFile("D:\1.ani"),OCR_NORMAL 即可。

系统会自动调用 DestroyCursor 来销毁。

Option Explicit

Private Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long

Private Declare Function SetSystemCursor Lib "user32" (ByVal hCur As Long, ByVal id As Long) As Long

Private Declare Function DestroyCursor Lib "user32" (ByVal hCur As Long) As Long

Private Const OCR_NORMAL = 32512

Dim lRet As Long

Private Sub Form_Load()

lRet = LoadCursorFromFile("D:\Icons\Standard Hand.cur")'我的图标路径

SetSystemCursor lRet, OCR_NORMAL

End Sub

Private Sub Command1_Click()

DestroyCursor(lRet)

End Sub

惨了……变不回去……必须要重设光标了。

但你可以设置单击“取消”后把鼠标换成系统鼠标图案,前提是你要有系统的鼠标文件

vb.net 中 怎么实现 当鼠标移动到某控件时 改变鼠标的形状

属性里面先把UseWaitCursor改为true然后再改Cursor的属性。选择一个你要的形状

在VB中能否通过键盘方向健来改变鼠标光标的位置

你好!

使用SENDKEY就可以了。如:

SENDKEY

{TAB}

则是相当于按了键盘上的TAB键

打字不易,采纳哦!

vb.net如何更换程序光标

比如你要更换在你某个窗体上的光标。

那么在这个窗体内用这样的代码

Me.Cursor = System.Windows.Forms.Cursors.Cross

如果你要更换当前系统显示的光标

System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Cross

其中Cross代表十字光标,你也可以更改成其他的,直接查看Cursors中的各成员就可以找到了。

VB.NET改变鼠标位置和让鼠标消失

几乎找不到真正VB.NET的api,都是自己将VB的api改成VB.NET的api,我的理解是声明中对应输入是H的地方保留Long,其他的Long改成Integer,既然VB.NET连MSDN都找不到较全的api说明,不保证api的用法在VB.NET其他版本中适用。

给你个好玩的例子,包括鼠标的隐藏(Ctrl_↓)、显示(Ctrl_↑),移动、点击

在Form1上放上2个TextBox,其中TextBox1.Multiline = True,并且面积大些,2个Button,运行后在TextBox1中点击一下会记录位置,移开鼠标,点击移动或点击Button,可模拟在TextBox1中的点击

Public Class Form1

Public My_MousePosition As Point

'模拟鼠标移动、点击

Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Integer, ByVal dy As Integer, ByVal cButtons As Long, ByVal dwExtraInfo As Long)

'定义光标的位置

Declare Function SetCursorPos Lib "user32" Alias "SetCursorPos" (ByVal x As Integer, ByVal y As Integer) As Integer

'鼠标的隐藏

Declare Function ShowCursor Lib "user32" Alias "ShowCursor" (ByVal bShow As Integer) As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

TextBox1.Multiline = True

Button1.Text = "点击"

Button2.Text = "移动"

Me.KeyPreview = True

End Sub

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

If e.Control And e.KeyCode = Keys.Down Then ShowCursor(0)

If e.Control And e.KeyCode = Keys.Up Then ShowCursor(1)

End Sub

Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove

TextBox2.Text = MousePosition.X " " MousePosition.Y

End Sub

Private Sub TextBox1_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TextBox1.MouseClick

My_MousePosition = MousePosition

TextBox1.Text = My_MousePosition.X " " My_MousePosition.Y vbCrLf

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

SetCursorPos(My_MousePosition.X, My_MousePosition.Y)

mouse_event(H2, 0, 0, 0, 0)

mouse_event(H4, 0, 0, 0, 0)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

SetCursorPos(My_MousePosition.X, My_MousePosition.Y)

End Sub

End Class

其中

mouse_event Lib "user32" (ByVal dwFlags As Long

的dwFlags的代码是

Const MOUSEEVENTF_LEFTDOWN = H2

Const MOUSEEVENTF_LEFTUP = H4

Const MOUSEEVENTF_MIDDLEDOWN = H20

Const MOUSEEVENTF_MIDDLEUP = H40

Const MOUSEEVENTF_MOVE = H1

Const MOUSEEVENTF_ABSOLUTE = H8000

Const MOUSEEVENTF_RIGHTDOWN = H8

Const MOUSEEVENTF_RIGHTUP = H10


新闻名称:vb.net修改鼠标光标,vb鼠标光标形状
当前路径:http://myzitong.com/article/hchidh.html