Sign in to follow this  
dist0rted

Cursor Problems

Recommended Posts

dist0rted    100
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).

Share this post


Link to post
Share on other sites
vovansim    336
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

Share this post


Link to post
Share on other sites
dist0rted    100
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.

Share this post


Link to post
Share on other sites
dist0rted    100
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this