How does spy++ find out what is the window at a certain point on the screen?

c++, spy++, winapi

Solution

There is a WindowFromPoint() function.

Problem

I am curious how spy++ Finder Tool finds out the window handle for the window over which the mouse is. Is there any WIN32 function for getting the handle of the topmost window that occupies a certain pixel on the display?

Original source