Reputation: 357
I'm wondering if getting the window handle of a window underneath the cursor's current position is possible in c++. I'm working on a screenshot program that can take partial screenshots and I think that a feature where you are able to take a screenshot of a window by pressing a hotkey when your cursor is over that window would be useful feature. Any ideas?
Upvotes: 5
Views: 13300
Reputation: 145204
The function you're looking for is WindowFromPoint
.
Upvotes: 11
Reputation: 15155
The following works:
POINT P;
HWND Handle;
GetCursorPos(&P);
Handle=WindowFromPoint(P);
Upvotes: 18