HOWTO: Translate Client Coordinates to Screen Coordinates

ID: Q11570


The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK)
  • Microsoft Win32 Software Development Kit (SDK)
  • Microsoft Windows 2000


SUMMARY

The GetClientRect function always returns the coordinates (0, 0) for the origin of a window. This behavior is documented in the "Microsoft Windows Software Development Kit (SDK) Programmer's Reference" manual.


MORE INFORMATION

To determine the screen coordinates for the client area of a window, call the ClientToScreen function to translate the client coordinates returned by GetClientRect into screen coordinates. The following code demonstrates how to use the two functions together:


   RECT rMyRect;

   GetClientRect(hwnd, (LPRECT)&rMyRect);
   ClientToScreen(hwnd, (LPPOINT)&rMyRect.left);
   ClientToScreen(hwnd, (LPPOINT)&rMyRect.right); 

Additional query words:

Keywords : kbNTOS kbWinOS2000 kbSDKWin32 kbGrpUser kbWinOS kbWndw
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbhowto


Last Reviewed: February 2, 2000
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.