Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / December 2007

Tip: Looking for answers? Try searching our database.

Changing the cursor

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dom - 31 Dec 2007 17:46 GMT
I need to change the cursor when the mouse is hovering over certain
cells in a DataViewGrid, as a visual aid for the user.  But the cursor
is not something found in the Cursors Class.  I have a .ICO file.

What is the most efficient way of doing this?  Is a way to build the
cursor resource right into the executable, so that it travels with
the EXE?  That seems to be the way other programs do it.  For example,
I have a resource viewer that lets me see all the resources in Excel,
and I can find Icons, Cursors, etc.

Right now, what I do is this.  In the load event of the main window, I
do m_AlternateCursor = new Cursor (<AppStartupPath>\filename), and I
plan to include the ICO file in the executable folder.
Nicholas Paldino [.NET/C# MVP] - 31 Dec 2007 18:04 GMT
Dom,

   That's what I would do.  You wouldn't have to worry about the file being
changed or deleted (of course, it means you have to recompile if the cursor
changes).

   You can just add the file to your project and set the compile action to
"embedded resource" and then you would call the GetManifestResourceStream
method on the Assembly class (the instance would represent the assembly you
are getting the embedded resource from).  You could then pass that Stream to
the Cursor class, and use it appropriately.

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

>I need to change the cursor when the mouse is hovering over certain
> cells in a DataViewGrid, as a visual aid for the user.  But the cursor
[quoted text clipped - 9 lines]
> do m_AlternateCursor = new Cursor (<AppStartupPath>\filename), and I
> plan to include the ICO file in the executable folder.
Peter Duniho - 31 Dec 2007 18:32 GMT
> I need to change the cursor when the mouse is hovering over certain
> cells in a DataViewGrid, as a visual aid for the user.  But the cursor
[quoted text clipped - 3 lines]
> cursor resource right into the executable, so that it travels with
> the EXE?

Yes, just add a new Icon resource to the Resources of your project, using  
the .ico file you have as the input.

You can then reference the icon from the Properties.Resources class of  
your project.

I do agree that this is better than trying to include a separate file in  
the same directory with your .exe, though assuming you're using a normal  
Setup program to install the program, it shouldn't matter much which way  
you do it since the user should never have to care about copying the files  
manually.

Pete

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.