問題:
如何設定鼠標指針?
方法一:
Private Declare Function alxSetCursor Lib "user32" Alias "SetCursor" (ByVal hCursor As Long) As Long
'將指定的鼠標指針設為當前指針
Private Declare Function alxGetCursor Lib "user32" Alias "GetCursor" () As Long
'獲取目前選擇的鼠標指針的句柄
Private Sub MouseType()
'取得左右形光標的值
Screen.MousePointer = 9 '設屏幕鼠標為9(左右型鼠標)。
lngMouSEOne = alxGetCursor() '返回左右型鼠標在Windows(2000\98\XP)的值。
Screen.MousePointer = 7 '設屏幕鼠標為11(沙漏)。
lngMouseTwo = alxGetCursor() '返回左右型鼠標在Windows(2000\98\XP)的值。
Screen.MousePointer = 0 '重設屏幕鼠標為0(Access自確定)。
blTextout = False
blTextlook = False
End Sub
方法二:
隨便找一個 .cur文件copy到mdb文件相同的目錄
Private Declare Function CopyCursor Lib "user32" Alias "CopyIcon" (ByVal hcur As Long) As Long
Private Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpstrCurFile As String) As Long
Private Declare Function GetCursor Lib "user32" () As Long
Private Declare Function SetSystemCursor Lib "user32" (ByVal hcur As Long, ByVal id As Long) As Long
Private Const OCR_NORMAL = 32512
dim lngMyCursor As Long
Dim lngSystemCursor As Long
Private Sub cmdMyCursor_Click() '更改指針樣式
Dim strCurFile As String
strCurFile = CurrentProject.Path + "\Cursor.cur"
'可隨意調用其他的.cur鼠標樣式文件,以達到顯示各種指針的目的
lngMyCursor = LoadCursorFromFile(strCurFile)
lngSystemCursor = GetCursor()
lngSystemCursor = CopyCursor(lngSystemCursor)
SetSystemCursor lngMyCursor, OCR_NORMAL
Text1.SetFocus
Text1.Text = "鼠標指針已經設定為您要的狀態"
cmdMyCursor.Enabled = False
cmdSystemCursor.Enabled = True
End Sub
private Sub cmdSystemCursor_Click() '恢復系統指針樣式
SetSystemCursor lngSystemCursor, OCR_NORMAL
Text1.SetFocus
Text1.Text = "鼠標指針已經恢復為系統狀態"
cmdMyCursor.Enabled = True
cmdSystemCursor.Enabled = False
lngSystemCursor = 0
End Sub
private Sub Form_Close()
If lngSystemCursor <> 0 Then SetSystemCursor lngSystemCursor, OCR_NORMAL
End Sub
private Sub Form_Unload(Cancel As Integer)
If lngSystemCursor <> 0 Then SetSystemCursor lngSystemCursor, OCR_NORMAL
End Sub