vb如何实现:经过图片时,指针变成手指?

 我来答
百度网友68f5c18
2012-04-13 · TA获得超过1730个赞
知道小有建树答主
回答量:792
采纳率:100%
帮助的人:858万
展开全部
vb中鼠标指针样式没有手指型的鼠标,但是可以调用系统API来实现

你可以使用API函数
SetCursor和LoadCursor实现

'新建一个标准模块,定义函数
Public Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
Public Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As String) As Long
'常量
Public Const IDC_HAND = "#32649"

'定义一个手指型鼠标保存的变量
Public hHandCursor As Long

在Form_Load事件中
hHandCursor = LoadCursor(0, IDC_HAND)

在图片的mousemove事件中
SetCursor hHandCursor
二白Q0
推荐于2016-09-04 · TA获得超过2413个赞
知道大有可为答主
回答量:990
采纳率:0%
帮助的人:1093万
展开全部
楼上的代码每次移动鼠标都触发事件,会比较耗费资源,而且在图片上按下鼠标时,指针会恢复成箭头,造成闪烁的感觉,下面的代码也是利用MouseIcon属性设置,但不需要手形的cur或ico文件。

Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As String) As Long
Private Const IDC_HAND = "#32649"

Private Declare Function OleCreatePictureIndirect Lib "olepro32.dll" (PicDesc As PicBmp, RefIID As GUID, ByVal fPictureOwnsHandle As Long, IPic As IPicture) As Long
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Type PicBmp
Size As Long
Type As Long
hBmp As Long
hPal As Long
Reserved As Long
End Type

Private Sub Form_Load()
Dim hHandCursor As Long
hHandCursor = LoadCursor(0, IDC_HAND)
Picture1.MouseIcon = CreatePicture(hHandCursor)
Picture1.MousePointer = 99
End Sub

'从hCursor句柄创建icon图像
Private Function CreatePicture(ByVal hCursor As Long) As StdPicture
Dim pic As PicBmp
Dim IID_IDispatch As GUID

With IID_IDispatch
.Data1 = &H20400
.Data4(0) = &HC0
.Data4(7) = &H46
End With

With pic
.Size = Len(pic)
.Type = vbPicTypeIcon
.hBmp = hCursor
.hPal = 0
End With
OleCreatePictureIndirect pic, IID_IDispatch, 1, CreatePicture
End Function
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友2032eaa
2012-04-13 · TA获得超过809个赞
知道大有可为答主
回答量:2149
采纳率:100%
帮助的人:1823万
展开全部
在mouseicon选择手型图标就可以
追问
这样不方便。变成手型图标时,会移位(即手型图标不是指向原来位置)
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 更多回答(1)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式