Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Windows Cursors

This topic is 6530 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How would I go about creating a color (Windows GDI) cursor at runtime from a bitmap? The cursor cannot be loaded from a resource file. It must be generated at runtime. I also cannot draw the cursor as part of the scene as the framerate is too low. Thanks in advance!

Share this post


Link to post
Share on other sites
Advertisement
Here''s my findings on cursors and DirectX:

When using a black and white cursor, (like the standard arrow cursor for example), if you are running fullscreen, the cursor may or may not flicker depending upon the video card. For example, I developed a game and since the cursor looked fine on my computer I assumed it was fine. When a friend tried it out, the cursor flashed badly...

Also, whenever I tried using a colored cursor, it flashed on ANY computer.

Once again, this is only if you''re running fullscreen - maybe also with flipping surfaces.

I can''t say how to do it in C++ - this was a couple years ago when I was using VB and DirectDraw.

Hope this helps somewhat... your only option might be to manually draw the cursor.

Clay

Share this post


Link to post
Share on other sites
i don''t know whether you can use this or not, but there is a function called
HCURSOR LoadCursorFromFile(LPCTSTR lpFileName);
it loads a cursor from a file, the file must be in .cur or .ani format. go figure...
heres another one, a LOT more complicated:HANDLE LoadImage(

HINSTANCE hinst, // handle of the instance containing the image
LPCTSTR lpszName, // name or identifier of image
UINT uType, // type of image
int cxDesired, // desired width
int cyDesired, // desired height
UINT fuLoad // load flags
);

from what i can tell (i got this from MSDN) you have to pass NULL as your hinstance so it doesn''t try to load it as a resource.
lpszName is the file name to load from.
uType should be IMAGE_CURSOR.
cxDesired and cyDesired are the x and y sizes of the cursor, use SM_CXCURSOR or SM_CYCURSOR for the defaults.
fuLoad (hehe) should be LR_LOADFROMFILE to load from a file.
happy codin, hope i helped.
farmersckn


Sometimes even chickens need to eat... Don't bang your head against a wall just to enjoy the good feeling when you stop.

Share this post


Link to post
Share on other sites
Thanks for the tips guys. For now I guess I''ll write the cursor to disk as a bitmap and then call loadImage on it.

If anyone else knows how to convert a bitmap to a cursor in RAM, that''d be great.

Share this post


Link to post
Share on other sites
If you have mouse trails on (Control Panel->Mouse) Your mouse may flicker in full screen mode.

--------------------------
Carpe Diem

Share this post


Link to post
Share on other sites
Thanks for the tip on LoadImage(). Starting from there, I looked around for a while, and finally stumbled upon CopyImage(). It looks like I can use that similarly to LoadImage(), except I can specify to copy a bitmap into a new cursor.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I have recently wroten a test program to show a series of cursors
under DirectDraw in VC++ with DirectX 7.0.
I can''t figure out what the cursor ''flashes'' is in your computer.
In my case, the cursor flash because I forgot to registe the class cursor as NULL. As a result, the cursor return to the system default one when mouse move, even though you have called the SetCursor(). And then, the cursor flashes....
After I registe the class cursor as NULL, this problem is disappear..

That''s my condition....

Hopes that would help you and sorry about my poor English..



Titan

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!