vb里怎样在窗体外部改变鼠标形状?

 我来答
zx001z7d53
2013-04-12 · TA获得超过2万个赞
知道大有可为答主
回答量:2.4万
采纳率:52%
帮助的人:5718万
展开全部
'永远改变系统鼠标指针
Option Explicit

Private Declare Function GetCurrentTime Lib "kernel32" Alias "GetTickCount" () As Long
Private Declare Function GetCursor Lib "user32" () As Long
Private Declare Function SetSystemCursor Lib "user32.dll" (ByVal hcur As Long, ByVal id As Long) As Long
Private Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Public Enum eCursorType
ecAppStarting = 32650 'The application starting (arrow and hourglass) cursor.
ecCross = 32515 'The cross-shaped cursor.
ecIBeam = 32513 'The text selection (I-beam) cursor.
ecIcon = 32641 'The empty icon cursor (Win NT only).
ecNo = 32648 'The circle with slash through it cursor.
ecNormal = 32512 'The normal arrow cursor.
ecSize = 32640 'The four-arrow resize/move cursor (Win NT only).
ecSizeAll = 32646 'The four-arrow resize/move cursor.
ecSizeNESW = 32643 'The double-arrow resize/move cursor pointing to the upper-right and lower-left.
ecSizeNS = 32645 'The double-arrow resize/move cursor pointing up and down.
ecSizeNWSE = 32642 'The double-arrow resize/move cursor pointing to the upper-left and lower-right.
ecSizeWE = 32644 'The double-arrow resize/move cursor pointing left and right.
ecUp = 32516 'The up arrow cursor.
ecWait = 32514 'The waiting (hourglass) cursor.
End Enum
'Purpose : Permanently changes the specified system cursor
'Inputs : eSysCursorType The system cursor to alter.
' sCursorPath The path of the new cursor to use.
'Outputs : Returns True on success
'Author : Andrew Baker
'Date : 31/01/2001 14:35
'Notes :
'Revisions :
Private Function SystemCursor(sCursorPath As String, eSysCursorType As eCursorType) As Boolean
Dim lhwndNewCursor As Long

If Len(Dir$(sCursorPath)) > 0 And Len(sCursorPath) > 0 Then
'Load the cursor from file
lhwndNewCursor = LoadCursorFromFile(sCursorPath)
Else
lhwndNewCursor = GetCursor()
End If

'Set the new system cursor
SystemCursor = CBool(SetSystemCursor(lhwndNewCursor, eSysCursorType)) 'Returns 1 if successful, or 0 if an error occured
End Function

Public Sub Delay(ByVal iiSecond As Integer)
Dim t As Long, t1 As Long, t2 As Long

t1 = GetCurrentTime
t2 = 0
t = iiSecond * 1000
Do Until t2 > t
DoEvents
t2 = GetCurrentTime - t1
Loop
End Sub

Private Sub Command1_Click()
Dim lbRet As Boolean

'鼠标的形状可以指定任意光标文件。在这里我可以不指定,直接用GetCursor--这个函数返回的是当前线程的指针
'不过好像鼠标变了以后不能恢复--不要破坏由hcur指定的指针——在必要的时候,它会由系统自行清除
'自己到E:\WINNT\Cursors下面去找个好点的光标吧
lbRet = SystemCursor(App.Path & "\3dgwe.cur", ecNormal)

Delay 5

lbRet = SystemCursor(App.Path & "\3dwarro.cur", ecNormal)
End Sub

Private Sub Form_Load()

End Sub
chinaboyzyq
2013-04-12 · TA获得超过1.3万个赞
知道大有可为答主
回答量:1.3万
采纳率:89%
帮助的人:3298万
展开全部
百度调用api改变鼠标形状。
追问
没找着
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式