|
-
Jan 28th, 2016, 04:40 PM
#12
Thread Starter
Member
Re: Change mouse's cursor outside form.
 Originally Posted by .paul.
try this:
Code:
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("user32.dll")> _
Private Shared Function SetSystemCursor(ByVal hCursor As IntPtr, ByVal id As Integer) As Boolean
End Function
<DllImport("user32.dll")> Private Shared Function LoadCursorFromFile(ByVal fileName As String) As IntPtr
End Function
<DllImport("user32.dll")> _
Public Shared Function CopyIcon(ByVal hIcon As IntPtr) As IntPtr
End Function
Const OCR_NORMAL As UInteger = 32512
Dim oldCursor As IntPtr
Private Sub Form1_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
SetSystemCursor(CopyIcon(oldCursor), OCR_NORMAL)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
oldCursor = CopyIcon(Cursors.Default.CopyHandle)
SetSystemCursor(CopyIcon(LoadCursorFromFile("C:\Users\-----\Desktop\-----\Textures\----- ----- --.cur")), OCR_NORMAL)
End Sub
End Class
YES, it works! Thanks 
(the only time it shows the default for a second is if I try to resize but that's not a problem because I'm gonna use this on an transparent form with the size of my screen)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|