FAQ Item: How to change the system’s cursor using VB.NET?

مؤمّن FAQ Item: How to change the system’s cursor using VB.NET?

مؤمّن

  • Monday, February 01, 2010 3:15 PM
    Moderator
     
     

    How to change the system’s cursor using VB.NET?


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

All Replies

  • Monday, February 01, 2010 3:15 PM
    Moderator
     
     Answered

    To modify the system’s cursor, we need to change items in the following registry:

    HKEY_CURRENT_USER\Control Panel\Cursors\

     

    After that, we call the Windows API SystemParametersInfo with SPI_SETCURSORS to force the system cursors reloaded.

     

    VB.NET codes:

    --------------------------------------------------

    #Region "SystemParametersInfo"

        Declare Function SystemParametersInfo Lib "User32" Alias "SystemParametersInfoA" ( _

            ByVal uAction As Integer, _

            ByVal uparam As Integer, _

            ByVal lpvParam As IntPtr, _

            ByVal fuWinIni As Integer) As Integer

     

        Private Const SPI_SETCURSORS = &H57

        Private Const NULL_PTR = 0

    #End Region

     

        Private Sub ButtonSend_Click( ... ) Handles ButtonSend.Click

            SystemParametersInfo(SPI_SETCURSORS, 0, NULL_PTR, 0)

    End Sub

    --------------------------------------------------

     

     

    Related threads:

    http://social.msdn.microsoft.com/forums/en-US/vbgeneral/thread/a0b5d97f-a9dd-448f-9a6a-fc2836f4f7df


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.