1,486
社区成员
发帖
与我相关
我的任务
分享
Private Sub Timer1_Timer()
Dim objCurImg As IPictureDisp
Dim hCursour As Long
Me.Cls
hCursour = GetCursor()
Debug.Print Hex(hCursour)
If (hCursour) Then
Set objCurImg = hIconToIcon(hCursour)
Print "X_size: " & ScaleX(objCurImg.Width, 8, 3)
Print "Y_size: " & ScaleY(objCurImg.Height, 8, 3)
PaintPicture objCurImg, 300, 450
End If
End Sub
Option Explicit
Private Declare Function GetCursor Lib "user32" () As Long
Private Declare Function OleCreatePictureIndirect Lib "oleaut32.dll" (pDicDesc As TypeIcon, _
riID As CLSID, ByVal fown As Long, lpUnk As Object) As Long
Private Type CLSID
'vID(15) As Byte '由16个成员组成的字节数组
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Type TypeIcon
cbSize As Long
picType As PictureTypeConstants
hIcon As Long
xExt As Long
yExt As Long
End Type
Private Function hIconToIcon(hIcon As Long) As IPictureDisp
Dim oNewPic As IPictureDisp
Dim stcCLSID As CLSID
Dim stcIconInfo As TypeIcon
Dim hRes As Long
stcCLSID.Data1 = &H7BF80980
stcCLSID.Data2 = &HBF32
stcCLSID.Data3 = &H101A
stcCLSID.Data4(0) = &H8B
stcCLSID.Data4(1) = &HBB
stcCLSID.Data4(2) = &H0
stcCLSID.Data4(3) = &HAA
stcCLSID.Data4(4) = &H0
stcCLSID.Data4(5) = &H30
stcCLSID.Data4(6) = &HC
stcCLSID.Data4(7) = &HAB
stcIconInfo.cbSize = Len(stcIconInfo)
stcIconInfo.picType = vbPicTypeIcon
stcIconInfo.hIcon = hIcon
hRes = OleCreatePictureIndirect(stcIconInfo, stcCLSID, -1, oNewPic)
If (hRes = 0) Then Set hIconToIcon = oNewPic
End Function
Private Sub Form_Load()
Timer1.Interval = 300
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim objCurImg As IPictureDisp
Me.Cls
Set objCurImg = hIconToIcon(GetCursor())
Print "X_size: " & ScaleX(objCurImg.Width, 8, 3)
Print "Y_size: " & ScaleY(objCurImg.Height, 8, 3)
PaintPicture objCurImg, 300, 450
End Sub