Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Posting Code/Help with Mouse Move

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

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; }

Share this post

Link to post
Share on other sites
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);

Share this post

Link to post
Share on other sites
posting in a hurry, but it should help. I


POINT point;


hdc = GetDC(hwnd);
ScreenToClient(hwnd, &point);
Rectangle(hdc, point.x, point.y, point.x+20, point.y+20);
ClientToScreen(hwnd, &point);

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]

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!