Posting Code/Help with Mouse Move

Started by
1 comment, last by BuddyLee 21 years ago
I was trying to make a program that everytime the mouse was moved and if it was in a positive coordinate that it would draw a rectangle where the mouse was. Just sort of fooling around with a snipet of code I wanted to use later. Here is my code, I cant figure out why it wont draw at all or even stop at a breakpoint in the procedure. Also how do you post code in those little boxes? Code: case WM_MOUSEMOVE: { hDC = BeginPaint( g_hWndMain, &PaintStruct ); int xPos; int yPos; xPos = LOWORD(lParam); yPos = HIWORD(lParam); Rectangle(hDC, xPos, yPos, xPos + 20, yPos + 20); if( xPos > 0 && yPos > 0) Rectangle(hDC, xPos, yPos, xPos + 20, yPos + 20); EndPaint( g_hWndMain, &PaintStruct ); return 0; }
Advertisement
I''m not sure but I think the values returned would be the amount moved since last time so try

// Global
int xPos;
int yPos;


// Local
xPos + = LOWORD(lParam);
yPos + = HIWORD(lParam);
posting in a hurry, but it should help. I


   LRESULT CALLBACK WndProc(.....);{ POINT  point;case WM_MOUSEMOVE:hdc = GetDC(hwnd);GetCursorPos(&point)ScreenToClient(hwnd, &point);Rectangle(hdc, point.x, point.y, point.x+20, point.y+20);ClientToScreen(hwnd, &point);ReleaseDC(hwnd,hdc);return 0;case WM_PAINT:hdc = BeginPaint(hwnd, &ps)  .  .  . EndPaint(hwnd, &ps);return 0;     


to make the nice little code box put the word "source" in
open and close brackets

-----------------------------
"There are ones that say they can and there are those who actually do."

"...u can not learn programming in a class, you have to learn it on your own."




[edited by - cMADsc on March 31, 2003 3:28:23 PM]
-----------------------------"There are ones that say they can and there are those who actually do.""...u can not learn programming in a class, you have to learn it on your own."

This topic is closed to new replies.

Advertisement