How to implement custom mouse cursor

  • Thread starter Thread starter Rud
  • Start date Start date
R

Rud

I'm still searching for an easy way to implement customized mouse pointers.
I've searched in the help text but couldn't get the answer. Do I have to dig
into the creation of resource files or is there a better alternative? Can I
use an imagelist like:

panel.cursor = imagelist.listimages(1) or something like this???

Kind regards, Rud
 
Rud said:
I'm still searching for an easy way to implement customized
mouse pointers. I've searched in the help text but couldn't
get the answer. Do I have to dig into the creation of resource
files or is there a better alternative?

This should work by embedding the cursor as a resource. The code in the
post referenced below demonstrates how to load an icon from the resources,
you can easily change it to work with cursor files by replacing 'Icon' with
'Cursor':

<URL:http://www.google.de/[email protected]>
 
Hi,

Add the cursor to the application and set its build action to
embedded resource. Here is an example that uses the pencil.cur included
with vs.net.


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim p As System.Reflection.Assembly =
System.Reflection.Assembly.GetExecutingAssembly()

Dim cur As Cursor

cur = New Cursor(p.GetManifestResourceStream(Me.GetType, "PENCIL.CUR"))

Me.Cursor = cur

End Sub

Private Sub Form1_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing

Me.Cursor = Cursors.Default

End Sub



Ken

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

I'm still searching for an easy way to implement customized mouse pointers.
I've searched in the help text but couldn't get the answer. Do I have to dig
into the creation of resource files or is there a better alternative? Can I
use an imagelist like:

panel.cursor = imagelist.listimages(1) or something like this???

Kind regards, Rud
 
Thanks for your help! So the trick is to set the "Build Action" of the
cursor file to "Embedded Rource" such that I can load the icons in the load
event of the form as follows:

curDefault = New Cursor(Me.GetType(), "cDefault.ico")

Rud
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top