Bitmap/Image to Cursor

J

James Hancock

I'm dynamically generating a cursor based on position (Cross hair with some
other information about where it is on the screen)

Right now I'm creating a Bitmap and putting everything on it, but the
problem is that I can't make it the current cursor.

I understand that the Cursor class is monochrome only, but I can't find a
way to save a bitmap as a cursor file (or stream).

Anyone have any ideas?

Thanks,
James Hancock
 
K

Ken Tucker [MVP]

Hi,

Dim bm As New Bitmap("c:\myImage.bmp")

Dim ptrCur As IntPtr = bm.GetHicon

Dim cur As Cursor

cur = New Cursor(ptrCur)



Ken
 
J

James Hancock

Ok, so that crashed my computer with a blue screen twice if the image is
over 32X32 in size....

Anyone know how to use the LoadCursor API function in this case? Then I can
use colors too which would be better because text looks horrible in 1bpp.

Thanks,
James Hancock
 
C

Crirus

By the way, I asked this question how to create a colored cursor 10 times
last 3 months... finally a solution
 
J

James Hancock

What solution?

The one below crashes any computer with the latest ATI Radeon drivers
installed, so I wouldn't call that a solution.

From what I can tell, the only way to do this right is to use a WinAPI call.
Anyone have a sample on how to do it? When I use LoadCursor I get a return
value of 0.

Thanks,
James Hancock
 
C

Crirus

As a conclusion is save to use this technique to design custom colored
cursors as cursors from resources are black/white (Doh)?
 
J

James Hancock

The solution is to use the Windows API to load the Icon. I just have yet to
find a good sample in any language to figure out how to do it.

So if anyone has one, please let me know.

James Hancock
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top