Reputation: 312
I am trying to get the size of an external window:
POINT point;
point.x = 100;
point.y = 100;
HWND hwnd = WindowFromPoint(point);
LPRECT pRect = {0};
bool ret1 = IsWindow(hwnd);
bool ret = GetWindowRect(hwnd, pRect);
The return value of IsWindow is true, but GetWindowRect fails with the following error:
1400: Invalid window handle
What can be wrong?
Upvotes: 0
Views: 3122
Reputation: 37132
It's not the window handle that's invalid, but the null pointer you're passing as the second parameter to GetWindowRect()
.
LPRECT pRect = {0};
This simply defines a pointer to a RECT
and initializes the pointer to 0. You need to provide an actual RECT
structure, as in:
RECT rc = { 0 };
GetWindowRect(hwnd, &rc);
Upvotes: 9