VB中如何捕捉到鼠标光标形状的改变?

来源:百度知道 编辑:UC知道 时间:2024/05/22 06:11:02
需要以下功能
程序运行的时候,因程序设置在不同部位鼠标形状会发生不同的改变(源程序中,me.mousepointer=0,即采用默设值,形状由对象决定)。
现在希望在运行中监测到鼠标光标形状的每次改变,应该怎么做?
最好附源码。

Private Declare Function GetCursor Lib "user32" () As Long
Private Declare Function CopyIcon Lib "user32" (ByVal hIcon As Long) As Long
Private Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long

Private Sub Command1_Click()
Dim x As Long
Dim h As Long
x = GetCursor
h = CopyIcon(x)
DrawIcon Me.hdc, 10, 10, h
Timer1.Enabled = True
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
Call Command1_Click
End Sub