Jump to content
  • Advertisement

Archived

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

BuddyLee

Posting Code/Help with Mouse Move

This topic is 5655 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
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);

Share this post


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

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!