[RESOLVED] How to add a cursor resource to my app (VC++ 2010 Express)
Well, maybe this would be easy if I had the Pro Edition with the integrated resource editor, but unfortunately I only have the Express Edition and tried to add a cursor resource from a .cur file to my app.
What I couldn't get to work:
Add the .cur file as a file resource to Form1.resX (right click on Form1.resX in the project explorer etc.) and try to construct the Cursor object using the Cursor(Type ^, String ^) constructor as described on MSDN. The resource option as described on the MSDN page for VB .NET and C# doesn't exist for cl. Maybe it could actually be done that way, but then I couldn't figure out how to obtain the correct Type ^ argument for the constructor.
Add a reference to the .cur file in the .rc file (by editing it manually), invoking the native LoadCursor() and trying the Cursor(IntPtr) constructor.
If I don't mess up my memory now, both of these attempts resulted in the Cursor constructor failing and thus gcnew returning nullptr.
I actually could construct the Cursor object from the .cur file on disk, but as the app consists only of a sole .exe file up to now, I didn't want to add the extra ballast of the .cur file.
I finally resorted to convert the .cur file to a bunch of hex literals (hidden inside the macro in the code below) and construct the Cursor from a MemoryStream constructed from the array<unsigned char>:
It took some considerable fiddling to get there and still feels like a hack somehow because I couldn't use the Cursor(Type ^, String ^) constructor, but it's still a big relief as it got me rid of that bulky hex array literal.
Maybe the pro version supports some kind of cursor type resource in the .resX file that the Express Edition doesn't, but having got that far still makes me feel really satisfied.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Bookmarks