H
H. Williams
I know the .Net Cursor class doesn't work with color cursors. So I'm
currently using the LoadCursorFromFile API with reflection to set color
cursors:
here is my code:
[DllImport("user32.dll")] public static extern IntPtr LoadCursorFromFile(
string fileName );
IntPtr hwdCursor= LoadCursorFromFile( "color.cur" );
myCursor.GetType().InvokeMember("handle",BindingFlags.Public |
BindingFlags.NonPublic |BindingFlags.Instance |
System.Reflection.BindingFlags.SetField,null,myCursor,new object [] {
hwdCursor} );
It works great, but I'd like to be able to embed the cursors. I've been
trying to get theLoadCursor API to work with embedded resources and I am not
having any luck.
here is the code that doesn't work:
[DllImport("user32.dll")] public static extern IntPtr LoadCursor( long hwd,
string fileName );
private static IntPtr hInstance =
Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]);
private static IntPtr hwdRedCursor=
LoadCursor((long)hInstance,"color.cur" );
Any suggestions?
currently using the LoadCursorFromFile API with reflection to set color
cursors:
here is my code:
[DllImport("user32.dll")] public static extern IntPtr LoadCursorFromFile(
string fileName );
IntPtr hwdCursor= LoadCursorFromFile( "color.cur" );
myCursor.GetType().InvokeMember("handle",BindingFlags.Public |
BindingFlags.NonPublic |BindingFlags.Instance |
System.Reflection.BindingFlags.SetField,null,myCursor,new object [] {
hwdCursor} );
It works great, but I'd like to be able to embed the cursors. I've been
trying to get theLoadCursor API to work with embedded resources and I am not
having any luck.
here is the code that doesn't work:
[DllImport("user32.dll")] public static extern IntPtr LoadCursor( long hwd,
string fileName );
private static IntPtr hInstance =
Marshal.GetHINSTANCE(Assembly.GetExecutingAssembly().GetModules()[0]);
private static IntPtr hwdRedCursor=
LoadCursor((long)hInstance,"color.cur" );
Any suggestions?