Re: Custom Cursor in Resource will not Load

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




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.

.



Relevant Pages

  • Re: Custom Cursor in Resource will not Load
    ... You have to use the command-line compiler with the options I ... >> methods to load it as a picture first, and then load it as a cursor. ... >> In order to get a cursor that you would load through LoadCursor, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: SetCursor()/LoadCursor() does not work.
    ... if you are trying to load a system cursor then you ... you will see that LoadCursor will return NULL; ... > AliR. ...
    (microsoft.public.vc.mfc)
  • Re: Loading a Different Cursor
    ... LoadCursor works just fine for me. ... I guess the real question is where you ... > different cursor.. ... > but it doesn't load a different cursor ...
    (microsoft.public.vc.mfc)
  • Re: Project proposal -- Forth project organiser
    ... they compile a call to an error routine instead. ... You load the file and each new defined word gets ... lot easier if people who write libraries do it your way. ... input buffer and check that it isn't a keeper word that hasn't been ...
    (comp.lang.forth)
  • Re: How to load and clear files?
    ... You can just load new definitions to replace the old ones. ... by the old name in the lisp image, ... CLISP is written in portable C code: you can compile it on almost any ... or:EXECUTE to precise your idea. ...
    (comp.lang.lisp)