A window's size and position are expressed as a bounding rectangle, given in coordinates relative to the screen or to the parent window. The coordinates of a top-level window are relative to the upper-left corner of the screen; the coordinates of a child window are relative to the upper-left corner of the parent window.
For example, a top-level window having the coordinates (10, 10) is placed 10 pixels to the right of the upper-left corner of the screen and 10 pixels down from it. A child window having the coordinates (10, 10) is placed 10 pixels to the right of the upper-left corner of its parent window's client area and 10 pixels down from the upper-left corner of that client area.
When you create a window, you can set the initial size and position of the window directly or direct the system to calculate the initial size and position by specifying CW_USEDEFAULT in the CreateWindow or CreateWindowEx function. After creating a window, you set the window's size or position by calling the MoveWindow or SetWindowPos function.
If you need to create a window with a client area of a particular size, use the AdjustWindowRectEx function to calculate the required size of a window based on the desired size of the client area. The application can pass the resulting size values to the CreateWindowEx function.
Though you can create a window of any size, you should not create one that is larger than the screen on your target device. Before setting a window's size, you should check the width and height of the screen by using GetSystemMetrics with the SM_CXSCREEN and SM_CYSCREEN flags.
You can use the GetWindowRect function to retrieve the coordinates of a window's bounding rectangle. GetWindowRect fills a RECT structure with the coordinates of the window's upper-left and lower-right corners. The coordinates are relative to the upper-left corner of the screen, even for a child window. The ScreenToClient or MapWindowPoints function maps the screen coordinates of a child window's bounding rectangle to coordinates relative to the parent window's client area.
The GetClientRect function retrieves the position and size of a window's client area. Because the coordinates are relative to the client area itself, the client area's upper-left corner is always at location (0, 0) and the coordinates of the lower-right corner are the width and height of the client area. Because the command bar is part of the client area in Windows CE, it is included in the dimensions returned by the GetClientRect function.
Use the WindowFromPoint function to retrieve the handle to the window that occupies a particular point on the screen. Use the ChildWindowFromPoint function to retrieve the handle to the child window that occupies a particular point in the parent window's client area. Use the ClientToScreen function to convert the client coordinates of a specified point to screen coordinates. Conversely, use the ScreentoClient function to convert the screen coordinates of a specified point into client coordinates.
Use the SetWindowPos function to change a window's position in the Z order. This function can place a window at the top of the Z order, at the bottom of the Z order, or behind a specific sibling window. SetWindowPos is the primary function for positioning windows. This function can change all aspects of a window's position and visibility.