I'm trying to add a custom cursor to a C# Winforms application as an embedded resource. It seems the embedding part is not working as the docs imply it should.
If I load the cursor from a file at runtime it woks just fine:
myMagCursor = new Cursor("../Resources/magnify.cur");
So it seems the cursor file is good. I followed this info on MSDN to embed the cursor (from the comments in the C# example):
//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"
And then tried to use it like this:
myMagCursor = new Cursor(GetType(), "magnify.cur");
Which gives a null reference exception, I assume because the resource is not found. I also tried this approach (found elsewhere on the web):
namespace Piccolo.Forms
{
public partial class Hanger
{
...
Assembly asm = Assembly.GetExecutingAssembly();
using( Stream resStream = asm.GetManifestResourceStream("Piccolo.magnify.cur") )
{
myMagCursor = new Cursor( resStream );
}
I've tried "Piccolo.magnify.cur", "Piccolo.Forms.magnify.cur", "Piccolo.Forms.Hanger.magnify.cur", "Hanger.magnify.cur" etc. I infer the cursor has not been embedded.
The cursor file is in a Resources folder with a bunch of .ico, .png and .jpg files that all work correctly as toolstrip buttons and appear in the 'Resources.resx' file(?) in the project. None of them have the "Embedded Resource" property. My cursor file does have the "Embedded Resource", but does not appear in 'Resources.resx'.
What am I missing with the cursor file to get it properly embedded?