Solved

Chnage to Custom Cursor

Posted on 2013-11-13
4
284 Views
Last Modified: 2013-11-21
Hi, I need to change the mouse curor inside my .NET program

I dont want to use windows defaults. i want to use a custom cursor saved inside the program

please help.
0
Comment
Question by:Ess Kay
  • 2
  • 2
4 Comments
 
LVL 30

Accepted Solution

by:
Alexandre Simões earned 500 total points
ID: 39647182
From MSDN documentation:
http://msdn.microsoft.com/en-us/library/system.windows.forms.cursor(v=vs.80).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-4

Imports System
Imports System.Drawing
Imports System.Windows.Forms

Namespace CustomCursor
   
   Public Class Form1
      Inherits System.Windows.Forms.Form
      
      <System.STAThread()> _
      Public Shared Sub Main()
         System.Windows.Forms.Application.Run(New Form1())
      End Sub 'Main

      Public Sub New()

         Me.ClientSize = New System.Drawing.Size(292, 266)
         Me.Text = "Cursor Example"
         
         ' Looks namespace.MyCursor.cur in the assemblies manifest.
         
         ' The following generates a cursor from an embedded resource.
         ' To add a custom cursor, create or use an existing 16x16 bitmap
         '        1. Add a new cursor file to your project: 
         '                File->Add New Item->Local Project Items->Cursor File
         '        2. Select 16x16 image type:
         '                Image->Current Icon Image Types->16x16
         ' --- To make the custom cursor an embedded resource  ---
         ' In Visual Studio:
         '        1. Select the cursor file in the Solution Explorer
         '        2. Choose View->Properties.
         '        3. In the properties window switch "Build Action" to "Embedded"
         ' On the command line:
         '        Add the following flag:
         '            /res:CursorFileName.Cur,Namespace.CursorFileName.Cur
         '
         ' The following line uses the namespace from the passed-in type
         ' and looks for CustomCursor.MyCursor.Cur in the assemblies manifest.
	 ' NOTE: The cursor name is acase sensitive.        
     
         Me.Cursor = New Cursor(Me.GetType(), "MyCursor.Cur") 
      End Sub 'New       
   End Class 'Form1
End Namespace 'CustomCursor

Open in new window


So the basic idea is to add the image to the project resources and then reference it.
0
 
LVL 15

Author Comment

by:Ess Kay
ID: 39648250
is that icon file able to take animation?>
0
 
LVL 30

Expert Comment

by:Alexandre Simões
ID: 39648394
It should... Make it as an animated gif and it should be ok.
0
 
LVL 15

Author Comment

by:Ess Kay
ID: 39648767
i want to use downloaded cursors
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question