A device context usually refers to a physical display device such as a video display or a printer. Often, you need to obtain information about this device, including the size of the display (in terms of both pixels and physical dimensions) and its color capabilities. You can get this information by calling the GetDeviceCaps (”get device capabilities“) function:
nValue = GetDeviceCaps (hdc, nIndex) ;
The nIndex parameter is 1 of 28 identifiers defined in WINDOWS.H. For instance, the nIndex HORZRES causes GetDeviceCaps to return the width of the device in pixels; a VERTRES parameter returns the height of the device in pixels. If hdc is a handle to a screen device context, that's the same information you can get from GetSystemMetrics. If hdc is a handle to a printer device context, then GetDeviceCaps returns the height and width of the printer display area in pixels.
You can also use GetDeviceCaps to determine the device's capabilities of processing various types of graphics. This is unimportant for the video display, but it becomes very important when working with printers. For instance, most plotters can't draw bitmapped images—and GetDeviceCaps can tell you that.