custom mouse pointer

mariano_donati

Active member
Joined
Nov 30, 2005
Messages
41
Programming Experience
Beginner
Hi everybody, i've made my simple own cursor using built-in capailities of VS. So, i have my file MyOwnCursor.cur, but now i don't know how to get it available to my application. That¡s my trouble and i really don't know how to solve it.
Regards.
 
Contrary to popular belief you dont just have to use cursor files as cusors in vb.net you can use .ico & .bmp aswell. The way i go about it is to set my cursor file as an embedded resource in my app. then use reflection to get the cursor that i want..... (Call this once in your class)

VB.NET:
Private CursorFName as string = (Your cursor file name.)
Private CustomCursor as cursor
 
Private Sub LoadCustomCursors() 
        Dim CurrentAssembly As String = _ 
    Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString() 
    Dim cursorFile As IO.Stream 

cursorFile = Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream( _ 
                                CurrentAssembly + "." + cursorFileName) 
customCursor = New Cursor(cursorFile) 
 
End Sub

Then to change the cursor to your custom cursor you would simply put..

VB.NET:
Cursor.Current = customCursor
 
You don't have to get all that complicated...
VB.NET:
'load cursor from file
Dim cur As New Cursor("MyOwnCursor.cur")
'set the forms cursor
Me.Cursor = cur
 
yea i know, but i adapted this code form the code i use in my apps where i store an array of cursor's in the rescource file. Theres a for next loop in the original code that i use to deterimine and pull out the cusor i want. Besides seeing different ways to do things can only be beneficial to people who are learning, as we all are i suppose.
 
Hey small problem, is it true that you can only import 16 color - cursor files. When i try to import a 24 or 16 bit one it loads as a black square.
 
Back
Top