Reputation: 367
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: 6
Views: 13354
Reputation: 145429
The function you're looking for is WindowFromPoint
.
Upvotes: 12
Reputation: 15185
The following works:
POINT P;
HWND Handle;
GetCursorPos(&P);
Handle=WindowFromPoint(P);
Upvotes: 19