// Create a CWnd object and get the window rectangle CWnd wnd; CRect rect; wnd.GetWindowRect(&rect);
// Create a CWnd object from a handle and get the window rectangle HWND hWindow = ::FindWindow(NULL, "My Window"); CWnd* pWnd = CWnd::FromHandle(hWindow); CRect rect; pWnd->GetWindowRect(&rect);This example retrieves the handle of a window named "My Window" using the FindWindow function, creates a CWnd object from the handle using the FromHandle function, and fetches its window rectangle using the GetWindowRect function. The retrieved size and coordinates are stored in a CRect object called rect. Both examples use the CWnd and CRect classes from the MFC library.