getcursorinfo

getcursorinfo是一個計算機系統函式。

基本介紹

  • 外文名:getcursorinfo
  • 所屬領域:計算機
Getcursorinfo API
windows下VB/VBA的編程函式用於取得整個桌面任意位置的滑鼠句柄
滑鼠句柄代表著滑鼠的特徵碼,獲取滑鼠句柄在很多場合有使用價值 【特別在遊戲中】
1.使用Getcursor API時只能獲取當前視窗的句柄,功能有限.
2.使用Getcursorinfo API 能獲取整個視窗任何位置的滑鼠句柄
Getcursorinfo 的使用方法比較囉嗦請按如下方法使用:
‘先申明函式
Public Declare Function GetCursorInfo Lib "user32.dll" (ByRef pci As CURSORINFO) As Boolean
’再建立需要用到的數據類型 CURSORINFO 及POINTAPI
Public Type POINTAPI '建立point的屬性,橫坐標與縱坐標
X As Long'point.x
Y As Long'point.y
End Type
Public Type CURSORINFO
cbSize As Long
' Specifies the size, in bytes, of the structure.
' The caller must set this to Marshal.SizeOf(typeof(CURSORINFO)).
flags As Long
' Specifies the cursor state. This parameter can be one of the following values:
' 0 The cursor is hidden.
' 1 The cursor is showing.
hCursor As Long
' Handle to the cursor.
ptScreenPos As POINTAPI
End Type
'最後調用此函式方法
DIM pci As CURSORINFO
pci.cbSize = Len(pci)
a = GetCursorInfo (pci)
'如果調用成功則a返回True 否則返回False
‘如果調用成功可使用如下取得滑鼠句柄等信息
pci.hcursor '滑鼠句柄
pci.ptScreenPos.X '滑鼠點x坐標
pci.ptScreenPos.Y '滑鼠點y坐標

熱門詞條

聯絡我們