MouseMove in Visual C++

Reply

Join Date: Jun 2006
Posts: 1,169
Reputation: Duki has a spectacular aura about Duki has a spectacular aura about Duki has a spectacular aura about 
Solved Threads: 9
Duki's Avatar
Duki Duki is offline Offline
Veteran Poster

MouseMove in Visual C++

 
0
  #1
Aug 22nd, 2008
Hey guys,

We're trying to work with a driver program for our robot. If we can grab the x and y coordinates of the Mouse we could send them to the controller for driving. Does anyone know how to capture the mouse movement into an integer?
It is practically impossible to teach good programming style to students that have had prior exposure to Basic; as potential programmers they are mentally mutilated beyond hope of regeneration.

-Edsger Dijkstra
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 376
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: MouseMove in Visual C++

 
0
  #2
Aug 22nd, 2008
maybe:
http://www.daniweb.com/forums/thread67435.html


  1. #include <windows.h>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. while ( 1 )
  8. {
  9. Sleep ( 500 );
  10. POINT pos;
  11. GetCursorPos ( &pos );
  12. // here is your coordinates
  13. int x = pos.x;
  14. int y = pos.y;
  15.  
  16. cout << "x pos:" << x << endl;
  17. cout << "y pos:" << y << endl << endl;
  18. }
  19. return 0;
  20. }

my output

  1. x pos:377
  2. y pos:272
  3.  
  4. x pos:377
  5. y pos:272
  6.  
  7. x pos:377
  8. y pos:272
  9.  
  10. x pos:585
  11. y pos:380
  12.  
  13. x pos:360
  14. y pos:142
  15.  
  16. x pos:379
  17. y pos:161
  18.  
  19. x pos:424
  20. y pos:271
  21.  
  22. x pos:424
  23. y pos:271
  24.  
  25. x pos:488
  26. y pos:302
  27.  
  28. x pos:502
  29. y pos:323
  30.  
  31. x pos:502
  32. y pos:323

I don't know about visual c++ but the above seems to work in dev-cpp I think.
Last edited by iamthwee; Aug 22nd, 2008 at 1:01 pm.
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC