Jump to content
  • Advertisement
Sign in to follow this  

Cursor Problems

This topic is 5098 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

Am I doing this correctly?

     LPPOINT lpCursor;
     SetRect(&rRect, lpCursor->x, lpCursor->y, lpCursor->x + 16, lpCursor->y + 16);

After this I BltFast() my Cursor bitmap (16 x 16) to the backbuffer. Yes, rRect is already defined. It works normally if I replace the top bottom right and left values with 0, 0, 16, 16, but I want a cursor. (I don't want to do it the Resource way, though.) If I use the code above my screen looks really weird and I have to turn off the power (CTRL + ALT + DELETE Doesn't work).

Share this post

Link to post
Share on other sites

If I am not mistaken LPPOINT is just POINT*?

If that's so, then you are violating memory when doing getCursor, because you got an unintialized pointer pointing god knows where.

It should be instead a struct like so:

POINT cursor;
SetRect(&rRect, cursor.x, cursor.y, cursor.x + 16, cursor.y + 16);


Share this post

Link to post
Share on other sites
I doubt it's the code you showed me, but for some reason the bitmap isn't showing up. Here's the code of my Main() function (after Setup() and Shutdown()).

void Main(void)

char sBuffer[] = "Press ESC to Exit.";


lpPrimarySurface->Flip(NULL, DDFLIP_WAIT);


SetRect(&rRect, 0, 0, 800, 600);
lpSecondarySurface->BltFast(0, 0, lpBackBitmap, &rRect, DDBLTFAST_WAIT);
SetRect(&rRect, pCursor.x, pCursor.y, pCursor.x + 16, pCursor.y + 16);
lpSecondarySurface->BltFast(0, 0, lpCursorBitmap, &rRect, DDBLTFAST_SRCCOLORKEY | DDBLTFAST_WAIT);


SetBkMode(hDeviceContext, TRANSPARENT);
SetTextColor(hDeviceContext, RGB(0, 255, 0));
SelectObject(hDeviceContext, GetStockObject(SYSTEM_FIXED_FONT));

TextOut(hDeviceContext, 100, 100, sBuffer, strlen(sBuffer));



When in SetRect, if I use 0, 0, 16, 16 it shows up in the top left corner fine.

Share this post

Link to post
Share on other sites
NEVER MIND. I fixed it.

I forgot that the RECT is just the dimensions within the file. I instead needed to put pCursor.x and pCursor.y as arguments 1 and 2 to BltFast().

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!