Results 1 to 6 of 6

Thread: Changing Windows Cursor

  1. #1

    Thread Starter
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282

    Changing Windows Cursor

    Does anyone have an example of using LoadCursor and SetCursor to change the Windows cursor ? I've tried it but the LoadCursor call just returns a handle of 0 which causes the SetCursor to make the cursor disappear. I'm using NT if that makes a difference, and here's the code I use :

    Code:
    ' Used to set the cursor to the crosshair on all app's
    Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorW" (ByVal hInstance As Long, ByVal lpCursorName As String) As Long
    Private Declare Function SetCursor Lib "user32" (ByVal hCursor As Long) As Long
    
    ' Crosshair cursor
    Private Const IDC_CROSS = 32515&
    
    Private Sub Command1_Click()
    
    Dim hCursor As Long
    Dim RetVal As Long
    
    ' Change the cursor to a crosshair - returns 0 at the moment !
    hCursor = LoadCursor(ByVal 0&, IDC_CROSS)
    RetVal = SetCursor(hCursor)
    
    End Sub
    Thanks in advance.
    That's Mr Mullet to you, you mulletless wonder.

  2. #2
    Megatron
    Guest
    You don't really need API For this.
    Code:
    Screen.MousePointer = 99
    Screen.MousePointer = LoadPicture(MyCursor.cur)
    To hide the Mouse, use the ShowCursor function.

  3. #3
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Actually the MouseIcon property should be used in the 2nd line.
    Or if you just want the crosshair:
    Code:
    Screen.MousePointer = vbCrosshair
    < (ignore, I must)

  4. #4
    Megatron
    Guest
    Yes, it should.
    (Sorry, I just copied and pasted the line)

  5. #5

    Thread Starter
    Hyperactive Member Paul Warren's Avatar
    Join Date
    Jun 2000
    Location
    UK
    Posts
    282
    Cheers guys, I was being particularly dim when I asked. I had API on the brain and didn't think VB might actually do it for me !
    That's Mr Mullet to you, you mulletless wonder.

  6. #6
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Don't worry - VB usually can't do much by itself anyway

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width