Cursor Problems

Started by
3 comments, last by dist0rted 19 years, 8 months ago
Am I doing this correctly?


     LPPOINT lpCursor;
     GetCursorPos(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).
=============================All knowledge is good; only the way it is put to use is good or evil.
Advertisement
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:

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


Vovan
Vovan
what he said
I'll give you a beating like Rodney King who deserved it!=====================================Any and all ideas, theories, and text c2004,c2009 BrainDead Software. All Rights Reserved.
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.";	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.
=============================All knowledge is good; only the way it is put to use is good or evil.
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().
=============================All knowledge is good; only the way it is put to use is good or evil.

This topic is closed to new replies.

Advertisement