下面的是一个VB的示例,供参考吧。
- Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
- Private Declare Function SetClassWord Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal wNewWord As Long) As Long
- Private Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
- Private Declare Function DestroyCursor Lib "user32" (ByVal hCursor As Long) As Long
- Const GCW_HCURSOR = (-12)
- Const IDC_SIZEALL = 32646&
- Dim SysCursHandle As Long, Curs1Handle As Long, Curs2Handle As Long
- Private Sub Form_Load()
- 'KPD-Team 1999
- 'URL: http://www.allapi.net/
- 'E-Mail: KPDTeam@Allapi.net
- 'Load a default cursor
- Curs1Handle = LoadCursor(ByVal 0&, IDC_SIZEALL)
- 'Load a cursor from a file
- Curs2Handle = LoadCursorFromFile("C:\Windows\Cursors\pen_1.cur")
- 'Set the form's mouse cursor
- SysCursHandle = SetClassWord(Me.hwnd, GCW_HCURSOR, Curs1Handle)
- 'Set the button's cursor
- SysCursHandle = SetClassWord(Command1.hwnd, GCW_HCURSOR, Curs2Handle)
- End Sub
- Private Sub Form_Unload(Cancel As Integer)
- 'Set the form's cursor back to the original cursor
- SetClassWord Me.hwnd, GCW_HCURSOR, SysCursHandle
- 'Clean up
- DestroyCursor Curs1Handle
- DestroyCursor Curs2Handle
- End Sub
|