Some applications must ensure that graphic output is centered in the client area. For example, spreadsheet applications often center graphs created by the user in the client area of a separate window. If your application falls into this category, you should determine the coordinates of the center of the client area and then treat that point as the origin for graphic-output operations.
The GetClientRect function returns the coordinates of the upper-left and lower-right corners of the client area. To determine the midpoint, you can retrieve these coordinates, determine the width and height of the rectangle, and divide these values by 2. However, it's important to realize that the coordinates returned by GetClientRect are device coordinates. (You can generally determine whether a function uses or returns device or world coordinates by examining the first argument. If this argument is a window handle, the function uses or returns device coordinates; if this argument is a device-context handle, the function uses or returns world coordinates.) Because most GDI functions require world (or logical) coordinates, it's necessary to convert the points returned by GetClientRect to world coordinates. This task is accomplished by calling the DPtoLP function.
The following illustration shows a simple front-view of a house that is centered in an application's client area. (The house measures 1.75 inches in height and 2 inches in width on any display—these consistent dimensions were obtained using the MM_LOENGLISH mapping mode):
Front View of House