Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004
    Location
    Glasgow, Scotland
    Posts
    107

    Unanswered: Change Mouse Pointer

    I am trying to put some bells and whistles on an application I am writing. I would like to chnage the mouse pointer to a hand icon (just like with a hyperlink) when it moves over a text box. Does anyone know how I can achieve this? I have tried various methods but they have so far proved unreliable.

    Thanks

  2. #2
    Join Date
    Feb 2004
    Location
    Swindon, UK
    Posts
    86
    To change the Mouse Icon, on a mouse over, call the following from the form.

    Private Sub TextBox1_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)

    MouseCursor (32649&)

    End Sub

    And add the below code to a Module.

    Option Compare Database
    Option Explicit

    Public Const IDC_APPSTARTING = 32650&
    Public Const IDC_HAND = 32649&
    Public Const IDC_ARROW = 32512&
    Public Const IDC_CROSS = 32515&
    Public Const IDC_IBEAM = 32513&
    Public Const IDC_ICON = 32641&
    Public Const IDC_NO = 32648&
    Public Const IDC_SIZE = 32640&
    Public Const IDC_SIZEALL = 32646&
    Public Const IDC_SIZENESW = 32643&
    Public Const IDC_SIZENS = 32645&
    Public Const IDC_SIZENWSE = 32642&
    Public Const IDC_SIZEWE = 32644&
    Public Const IDC_UPARROW = 32516&
    Public Const IDC_WAIT = 32514&

    Declare Function LoadCursorBynum Lib "user32" Alias "LoadCursorA" _
    (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long

    Declare Function LoadCursorFromFile Lib "user32" Alias _
    "LoadCursorFromFileA" (ByVal lpFileName As String) As Long

    Declare Function SetCursor Lib "user32" _
    (ByVal hCursor As Long) As Long

    Function MouseCursor(CursorType As Long)
    Dim IngRet As Long
    IngRet = LoadCursorBynum(0&, CursorType)
    IngRet = SetCursor(IngRet)
    End Function

    Function PointM(strPathToCursor As String)
    Dim IngRet As Long
    IngRet = LoadCursorFromFile(strPathToCursor)
    IngRet = SetCursor(IngRet)
    End Function
    Last edited by Mowgli212001; 04-20-04 at 12:46.

  3. #3
    Join Date
    Mar 2004
    Location
    Glasgow, Scotland
    Posts
    107
    Many thanks, that works perfectly.

    Originally posted by Mowgli212001
    To change the Mouse Icon, on a mouse over, call the following from the form.

    Private Sub TextBox1_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)

    MouseCursor (32649&)

    End Sub

    And add the below code to a Module.

    Option Compare Database
    Option Explicit

    Public Const IDC_APPSTARTING = 32650&
    Public Const IDC_HAND = 32649&
    Public Const IDC_ARROW = 32512&
    Public Const IDC_CROSS = 32515&
    Public Const IDC_IBEAM = 32513&
    Public Const IDC_ICON = 32641&
    Public Const IDC_NO = 32648&
    Public Const IDC_SIZE = 32640&
    Public Const IDC_SIZEALL = 32646&
    Public Const IDC_SIZENESW = 32643&
    Public Const IDC_SIZENS = 32645&
    Public Const IDC_SIZENWSE = 32642&
    Public Const IDC_SIZEWE = 32644&
    Public Const IDC_UPARROW = 32516&
    Public Const IDC_WAIT = 32514&

    Declare Function LoadCursorBynum Lib "user32" Alias "LoadCursorA" _
    (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long

    Declare Function LoadCursorFromFile Lib "user32" Alias _
    "LoadCursorFromFileA" (ByVal lpFileName As String) As Long

    Declare Function SetCursor Lib "user32" _
    (ByVal hCursor As Long) As Long

    Function MouseCursor(CursorType As Long)
    Dim IngRet As Long
    IngRet = LoadCursorBynum(0&, CursorType)
    IngRet = SetCursor(IngRet)
    End Function

    Function PointM(strPathToCursor As String)
    Dim IngRet As Long
    IngRet = LoadCursorFromFile(strPathToCursor)
    IngRet = SetCursor(IngRet)
    End Function

  4. #4
    Join Date
    Feb 2004
    Location
    Swindon, UK
    Posts
    86
    Not a problem

Posting Permissions

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