You are here:

C++/absolute coordinate of mouse pointer ...

Advertisement


Question
 hello sir,
 I want to write a program which tells me the (absolute) coordinate of where the mouse is clicked on(POINT data structure) or where the mouse is located. This coordinate can be outside the boundaries of my application's form.
 
 Microsoft visual studio 6 has a tool, called SPY++, which does a somehow similar task: it retrieves the handle of the window above which the mouse is moving.

 My probblem is that when the mouse is clicked somewhere I lose the focus in my application. What should I do to solve this problem(losing the focus OnClick)?

thank you very very much.  

Answer
mohammad, Thank you for your question.

Spy++ requires the user to drag an icon over windows to select them. It uses the 'SetCapture' function to do this. You can search Microsoft's MSDN Library for 'SetCapture' at http://search.microsoft.com/us/dev/default.asp. While the mouse is 'captured', WM_MOUSEMOVE and other messages are sent to the application window specified in the call to 'SetCapture'.

David Spector

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


David Spector

Expertise

Highly knowledgeable in the C++ language, Visual C++ (MSVC), Windows API, documentation and other quality-assurance techniques, and debugging. Knowledgeable in MFC, COM, GUI design, and object-oriented design.

Experience

I have been a software engineer since 1965. I have been published. My specializations have been: biomedical programming, compiler implementation, and many kinds of Windows programming. I don't do Databases or other business-oriented stuff.

Publications
Windows?/DOS Developer's Journal, ACM SIGPLAN Notices, and Computer Science Press.

Education/Credentials
ICCP Systems Programming Certification
Master's degree equivalent in Computer Science

©2016 About.com. All rights reserved.