This is because you use .ICO files instead of .CUR files as data for the Cursor class.
While the .ICO and .CUR formats are similar, the .ICO format does not contain hot spot information.
You have 2 options:
convert your .ICO files to .CUR files and embed them as resources.
Do this using the conversion utility that you can find on the Internet, or create a new .CUR file in Visual Studio, and then copy and paste the data from your .ICO files.
save them as .ICO files, but crack the data so that it matches the CUR format when passing to the Cursor class.
Here is a sample code to change the ICO stream to turn it into a CUR format.
In this example, I tested it with an ICO file that contained one 32X32X4bit BMP image, and I wanted the cursor to have a (15.15) hot spot.
This code is only intended to get started if you go along this route ... it needs more code to handle errors and the ability to work with ICO files that contain several icon images (that is, if there are several entries), etc. d.
You can also use BinaryWriter for more natural data management, for example. to write hotspots coords that use 2 bytes (i.e. more than 255) using Write(UInt16) .


using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.IO; using System.Windows.Resources; namespace WpfApplication2 {
<Window x:Class="WpfApplication2.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> </Grid> </Window>
source share