Ok, the last post in this thread is already one month ago and the thread is [RESOLVED], but I think it's worth noting that this leaks memory:

Quote Originally Posted by RogerD View Post
Code:
System::Drawing::Rectangle^ Win32::GetWindowRect(Point pt)
{
  POINT ptNative = {pt.X, pt.Y};
  HWND hwnd = ::WindowFromPoint(ptNative);
  LPRECT rect = new RECT;
  ::GetWindowRect(hwnd,rect);
  return System::Drawing::Rectangle(rect->left,rect->top,rect->right-rect->left,rect->bottom-rect->top);
}
The dynamically allocated rect is never released. Actually, there's no need to dynamically allocate it anyway. The reason why I dynamically allocated lpNativeText in Win32::GetWindowText_() was that I couldn'd know its size in advance, which is not the case with the fixed-size RECT structure. Here's a fixed version:

Code:
Drawing::Rectangle^ Win32::GetWindowRect(Point pt)
{
  POINT ptNative = {pt.X, pt.Y};
  HWND hwnd = ::WindowFromPoint(ptNative);
  RECT rect;
  ::GetWindowRect(hwnd, &rect);
  return Drawing::Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
}