You can get the position of the mouse cursor, no matter where it is. To transform the coordinates in the coordinate system of your window, you can use the screen coordinates of your window.
But the problem is: what event would trigger your code? You respond to mouse events outside of your application, you would need to
capture the mouse. This is how:
SetCapture function (Windows)[
^],
ReleaseCapture function (Windows)[
^],
GetCapture function (Windows)[
^].
See also my comment to Solution 1.
—SA