Skip to main content
gamedev.net
🔒 Locked

Managed DirectDraw Cursor?

Started by Sir_Brizz Mar 12, 2005 at 9:35 PM 3 replies 800+ views
Original Post
Sir_Brizz
Sir_Brizz
hey all, I am writing a windowed DirectDraw program in Managed C++ and I'm havig some trouble. I have set up the program to do everything I want so far, except for one thing. The Windows Cursor is always the one that is used throughout the whole program. However, I want to be able to load a bitmap in and display it as the cursor. I can't figure out how to do this, though, because I want the cursor to only be a portion of the bitmap and only when it is over a specific surface, otherwise it should be the regular windows cursor. My problem is that I can't figure out how to make the cursor a bitmap. The Cursor class only support Black and White cursors, so I can't use that route. Does anyone know how this would be done in managed DirectDraw or can explain how I would do it in normal DirectDraw? Thanks!
It''s coming...Blox - an old new world at www.jaren.org
Brocketino
Brocketino
Dont now about managed ddraw but i think you should respond to the WM_SETCURSOR message ( sent when the cursor moves into a window, who hasnt captured the mouse ), by loading and select your own cursor.
Sir_Brizz
Sir_Brizz
well in the Managed libraries there is a Cursor class, but it only supports Black and White cursors. That class handles all of the Cursor states for a managed form.

I was hoping there was a prettier way to do it with DDraw somehow.
It''s coming...Blox - an old new world at www.jaren.org
Bad Maniac
Bad Maniac
* Load the cursor bitmap to a DDraw surface
* Turn off the system cursor
* Draw your frame as usual
* Blit the cursor surface at mouseX, mouseY at the very end of each frame before flipping the back buffer

There you go. As fancy a cursor as you'd wish. you can load a series of cursors onto a surface and have an animated cursor as well. Treat the cursor like a sprite, but make sure it's always the very last thing that get's blitted each frame.

This aproach has some drawbacks, choppy mouse at low FPS and other such things. But solving them is beyond the scope of this post and left as a research assignment for the reader ;)
Sir_Brizz
Sir_Brizz
Thanks, what I was thinking, but I hoped it would be possible throuh the class hierarchy. Still, worked perfectly this way, so I'm not worried about it in a 2D application.

Thanks!
It''s coming...Blox - an old new world at www.jaren.org

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.