The Windows Help Coordinate System

When defining windows, you use the Help coordinate system to specify window position and size values. Help uses its own device-independent coordinate system because the screen resolution, or number of pixels, on Windows displays can vary. This device-independent system divides the screen into 1024 vertical units and 1024 horizontal units. When Help displays a Help file, it converts the size and position values specified by the Help file into values appropriate to the resolution of the display device. This allows Help to display Help windows using a consistent size and location despite variations in screen resolution.

The Help coordinate system is mapped to the horizontal and vertical resolutions of the video card, so you’ll have to do some calculations to determine the exact pixel location. For example, if the resolution of your video card is horiz by vert pixels, and the horizontal and vertical locations you specify are at Windows Help coordinates x and y, then the x-coordinate of the upper-left corner is at the pixel given by the following formula:

x * (horiz/1024)

The y-coordinate of the upper-left corner is at the pixel given by the following formula:

y * (vert/1024)

The window’s width and height are also specified in Help’s coordinate system. For example, a window may specify a width of 511 and a height of 511. A standard VGA card has a resolution of 640-by-480 pixels, so the width is actually the following number of pixels:

511 * (640/1024) = 319

The height is actually the following number:

511 * (480/1024) = 240

In other words, the window would take up approximately one quarter of the area of the Windows Help screen (half the width multiplied by half the height).

To convert from pixels to Windows Help coordinates, you invert the ratio between Windows Help’s resolution and the video resolution. Again, assuming the resolution of your video card is horiz by vert pixels, and the horizontal and vertical locations (or dimensions) you want are x and y pixels, the x-coordinate (or width), in Windows Help coordinates, is as follows:

x * (1024/horiz)

The y-coordinate (or height), in Windows Help coordinates, is:

y * (1024/vert)

Because the Windows Help coordinate system ranges from 0 through 1023 in both directions, the horizontal position plus the width must be less than or equal to 1023. Similarly, the vertical position plus the height must be less than or equal to 1023.