Re: Custom Cursor in Resource will not Load
- From: Paul Cheetham <PAC.News@xxxxxxxxxxxxx>
- Date: Sun, 01 Jan 2006 10:36:47 +0000
Nicholas,
Thankyou for your help.
I will try your suggestion - I will create a Win32 .rc file and compile it into my project (I am assuming there will be a way to do this in VS 2003)
Hopefully it should be reasonably straight forward from there.
Thankyou again.
Paul
Nicholas Paldino [.NET/C# MVP] wrote:
Paul,
Looking into this, it seems that ultimately, it uses some of the Ole methods to load it as a picture first, and then load it as a cursor. I think that along the way, this is where the colors get skewed.
In order to get a cursor that you would load through LoadCursor, you will have to compile through the command line (or adjust the tasks in your project file if you are using .NET 2.0 with MSBUILD). You can use the /win32res flag to embed a Win32 resource.
This means you will have to create a .rc file, run it through the Resource Compiler (used in Visual C++ typically) and then point to the resulting .res file with the /win32res flag.
Once you do that, in your code, you can call LoadCursor through the P/Invoke layer. You to get the handle, you would pass the Module (in most assemblies, there is only one Module, but you can create multi-module assemblies) to the static GetHINSTANCE method on the Marshal class. You would then pass this handle as the first parameter in the LoadCursor method. Then, you should have your cursor handle, and you can pass that to the Cursor object.
.
- Follow-Ups:
- Re: Custom Cursor in Resource will not Load
- From: Nicholas Paldino [.NET/C# MVP]
- Re: Custom Cursor in Resource will not Load
- Prev by Date: protected and private in C++ and C#
- Next by Date: Re: Why is C# 450% slower than C++ on nested loops ??
- Previous by thread: protected and private in C++ and C#
- Next by thread: Re: Custom Cursor in Resource will not Load
- Index(es):
Relevant Pages
|