LPPOINT lpCursor;
GetCursorPos(lpCursor);
SetRect(&rRect, lpCursor->x, lpCursor->y, lpCursor->x + 16, lpCursor->y + 16);
Cursor Problems
Am I doing this correctly?
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).
Hi,
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:
Vovan
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;GetCursorPos(&cursor);SetRect(&rRect, cursor.x, cursor.y, cursor.x + 16, cursor.y + 16);
Vovan
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()).
When in SetRect, if I use 0, 0, 16, 16 it shows up in the top left corner fine.
void Main(void){ char sBuffer[] = "Press ESC to Exit."; GetCursorPos(&pCursor); lpPrimarySurface->Flip(NULL, DDFLIP_WAIT); if (KEYDOWN(VK_ESCAPE)) { PostQuitMessage(0); } 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); lpSecondarySurface->GetDC(&hDeviceContext); SetBkMode(hDeviceContext, TRANSPARENT); SetTextColor(hDeviceContext, RGB(0, 255, 0)); SelectObject(hDeviceContext, GetStockObject(SYSTEM_FIXED_FONT)); TextOut(hDeviceContext, 100, 100, sBuffer, strlen(sBuffer)); lpSecondarySurface->ReleaseDC(hDeviceContext);}
When in SetRect, if I use 0, 0, 16, 16 it shows up in the top left corner fine.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement