954,568 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

change cursor

i want my program able to change cursor at runtime.
give a hand pleasee....
thanks all...

ITKnight
Light Poster
48 posts since Jan 2008
Reputation Points: 11
Solved Threads: 1
 

try this followong code :

'This example requires two command buttons
Private Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Private Declare Function CopyIcon Lib "user32" (ByVal hIcon As Long) As Long
Private Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
Private Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
Private Declare Function SetSystemCursor Lib "user32" (ByVal hcur As Long, ByVal id As Long) As Long
Private Declare Function GetCursor Lib "user32" () As Long
Private Const OCR_NORMAL As Long = 32512
Private currenthcurs As Long
Private tempcurs As Long
Private newhcurs As Long
Private Sub Command1_Click()
    Dim myDir As String
    Dim lDir As Long
    myDir = Space(255)
    currenthcurs = GetCursor()
    tempcurs = CopyIcon(currenthcurs)
    lDir = GetWindowsDirectory(myDir, 255)
    myDir = Left$(myDir, lDir) & "\cursors\banana.ani"
    newhcurs = LoadCursorFromFile(myDir)
    Call SetSystemCursor(newhcurs, OCR_NORMAL)
End Sub
Private Sub Command2_Click()
    Call SetSystemCursor(tempcurs, OCR_NORMAL)
End Sub

Hope this helps...

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

Hi,

Write this in FormLoad event:

Me.MousePointer = 99
Me.MouseIcon = LoadPicture("C:\windows\cursors\3dgno.cur")


Change the path accordingly

Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

bravo...
thank you very much all...

ITKnight
Light Poster
48 posts since Jan 2008
Reputation Points: 11
Solved Threads: 1
 

you're welcome friend :)

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

hei..this thread help me too.
thank you all :)

dnk
Light Poster
49 posts since Dec 2007
Reputation Points: 35
Solved Threads: 0
 

glad to share our knowledge with u :)
Happy coding

Jx_Man
Nearly a Senior Poster
3,329 posts since Nov 2007
Reputation Points: 1,372
Solved Threads: 444
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You