You are here:

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


 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.  

Hello mohammad,

If you make a POINT object and pass it to the function GetCursorPos it will fill out the structure with the absolute mouse points.

I know one way to test focuses, like in your WinMain, you can do :

if(GetFocus() == hWnd)

to test if youre inside the current window.

I hope this was helpful  


All Answers

Answers by Expert:

Ask Experts




I can answer questions about the C++ language, object oriented design and architecture. I am knowledgable in a lot of the math that goes into programming, and am certified by I also know a good deal about graphics via OpenGL, and GUIs.


I have completed numerous games and demos created with the C++ programming language. Currently employed as a software engineer in the modeling and simulation field. I have about 7 years experience.

©2016 All rights reserved.