Click to Rate and Give Feedback
MSDN
MSDN Library
Windows GDI
Device Contexts
 GetDeviceCaps
Windows GDI
GetDeviceCaps

The GetDeviceCaps function retrieves device-specific information for the specified device.

int GetDeviceCaps(
  HDC hdc,     // handle to DC
  int nIndex   // index of capability
);

Parameters

hdc
[in] Handle to the DC.
 
nIndex
[in] Specifies the item to return. This parameter can be one of the following values.
IndexMeaning
DRIVERVERSIONThe device driver version.
TECHNOLOGYDevice technology. It can be any one of the following values.
 DT_PLOTTERVector plotter
 DT_RASDISPLAYRaster display
 DT_RASPRINTERRaster printer
 DT_RASCAMERARaster camera
 DT_CHARSTREAMCharacter stream
 DT_METAFILEMetafile
 DT_DISPFILEDisplay file
 If the hdc parameter is a handle to the DC of an enhanced metafile, the device technology is that of the referenced device as specified to the CreateEnhMetaFile function. To determine whether it is an enhanced metafile DC, use the GetObjectType function.
HORZSIZEWidth, in millimeters, of the physical screen.
VERTSIZEHeight, in millimeters, of the physical screen.
HORZRESWidth, in pixels, of the screen; or for printers, the width, in pixels, of the printable area of the page.
VERTRESHeight, in raster lines, of the screen; or for printers, the height, in pixels, of the printable area of the page.
LOGPIXELSXNumber of pixels per logical inch along the screen width. In a system with multiple display monitors, this value is the same for all monitors.
LOGPIXELSYNumber of pixels per logical inch along the screen height. In a system with multiple display monitors, this value is the same for all monitors.
BITSPIXELNumber of adjacent color bits for each pixel.
PLANESNumber of color planes.
NUMBRUSHESNumber of device-specific brushes.
NUMPENSNumber of device-specific pens.
NUMFONTSNumber of device-specific fonts.
NUMCOLORSNumber of entries in the device's color table, if the device has a color depth of no more than 8 bits per pixel. For devices with greater color depths,  1 is returned.
ASPECTXRelative width of a device pixel used for line drawing.
ASPECTYRelative height of a device pixel used for line drawing.
ASPECTXYDiagonal width of the device pixel used for line drawing.
PDEVICESIZEReserved.
CLIPCAPSFlag that indicates the clipping capabilities of the device. If the device can clip to a rectangle, it is 1. Otherwise, it is 0.
SIZEPALETTENumber of entries in the system palette. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with 16-bit Windows.
NUMRESERVEDNumber of reserved entries in the system palette. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with 16-bit Windows.
COLORRESActual color resolution of the device, in bits per pixel. This index is valid only if the device driver sets the RC_PALETTE bit in the RASTERCAPS index and is available only if the driver is compatible with 16-bit Windows.
PHYSICALWIDTHFor printing devices: the width of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5-x11-inch paper has a physical width value of 5100 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller.
PHYSICALHEIGHTFor printing devices: the height of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5-by-11-inch paper has a physical height value of 6600 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller.
PHYSICALOFFSETXFor printing devices: the distance from the left edge of the physical page to the left edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5-by-11-inch paper, that cannot print on the leftmost 0.25-inch of paper, has a horizontal physical offset of 150 device units.
PHYSICALOFFSETYFor printing devices: the distance from the top edge of the physical page to the top edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5-by-11-inch paper, that cannot print on the topmost 0.5-inch of paper, has a vertical physical offset of 300 device units.
VREFRESHWindows NT/2000/XP: For display devices: the current vertical refresh rate of the device, in cycles per second (Hz).

A vertical refresh rate value of 0 or 1 represents the display hardware's default refresh rate. This default rate is typically set by switches on a display card or computer motherboard, or by a configuration program that does not use display functions such as ChangeDisplaySettings.

SCALINGFACTORXScaling factor for the x-axis of the printer.
SCALINGFACTORYScaling factor for the y-axis of the printer.
BLTALIGNMENTWindows NT/2000/XP: Preferred horizontal drawing alignment, expressed as a multiple of pixels. For best drawing performance, windows should be horizontally aligned to a multiple of this value. A value of zero indicates that the device is accelerated, and any alignment may be used.
SHADEBLENDCAPSWindows 98/Me, Windows 2000/XP: Value that indicates the shading and blending capabilities of the device. See Remarks for further comments.
 SB_CONST_ALPHAHandles the SourceConstantAlpha member of the BLENDFUNCTION structure, which is referenced by the blendFunction parameter of the AlphaBlend function.
 SB_GRAD_RECTCapable of doing GradientFill rectangles.
 SB_GRAD_TRICapable of doing GradientFill triangles.
 SB_NONEDevice does not support any of these capabilities.
 SB_PIXEL_ALPHACapable of handling per-pixel alpha in AlphaBlend.
 SB_PREMULT_ALPHACapable of handling premultiplied alpha in AlphaBlend.
RASTERCAPSValue that indicates the raster capabilities of the device, as shown in the following table.
 RC_BANDINGRequires banding support.
 RC_BITBLTCapable of transferring bitmaps.
 RC_BITMAP64Capable of supporting bitmaps larger than 64 KB.
 RC_DI_BITMAPCapable of supporting the SetDIBits and GetDIBits functions.
 RC_DIBTODEVCapable of supporting the SetDIBitsToDevice function.
 RC_FLOODFILLCapable of performing flood fills.
 RC_PALETTESpecifies a palette-based device.
 RC_SCALINGCapable of scaling.
 RC_STRETCHBLTCapable of performing the StretchBlt function.
 RC_STRETCHDIBCapable of performing the StretchDIBits function.
CURVECAPSValue that indicates the curve capabilities of the device, as shown in the following table.
 CC_NONEDevice does not support curves.
 CC_CHORDDevice can draw chord arcs.
 CC_CIRCLESDevice can draw circles.
 CC_ELLIPSESDevice can draw ellipses.
 CC_INTERIORSDevice can draw interiors.
 CC_PIEDevice can draw pie wedges.
 CC_ROUNDRECTDevice can draw rounded rectangles.
 CC_STYLEDDevice can draw styled borders.
 CC_WIDEDevice can draw wide borders.
 CC_WIDESTYLEDDevice can draw borders that are wide and styled.
LINECAPSValue that indicates the line capabilities of the device, as shown in the following table:
 LC_NONEDevice does not support lines.
 LC_INTERIORSDevice can draw interiors.
 LC_MARKERDevice can draw a marker.
 LC_POLYLINEDevice can draw a polyline.
 LC_POLYMARKERDevice can draw multiple markers.
 LC_STYLEDDevice can draw styled lines.
 LC_WIDEDevice can draw wide lines.
 LC_WIDESTYLEDDevice can draw lines that are wide and styled.
POLYGONALCAPSValue that indicates the polygon capabilities of the device, as shown in the following table.
 PC_NONEDevice does not support polygons.
 PC_INTERIORSDevice can draw interiors.
 PC_POLYGONDevice can draw alternate-fill polygons.
 PC_RECTANGLEDevice can draw rectangles.
 PC_SCANLINEDevice can draw a single scanline.
 PC_STYLEDDevice can draw styled borders.
 PC_WIDEDevice can draw wide borders.
 PC_WIDESTYLEDDevice can draw borders that are wide and styled.
 PC_WINDPOLYGONDevice can draw winding-fill polygons.
TEXTCAPSValue that indicates the text capabilities of the device, as shown in the following table.
 TC_OP_CHARACTERDevice is capable of character output precision.
 TC_OP_STROKEDevice is capable of stroke output precision.
 TC_CP_STROKEDevice is capable of stroke clip precision.
 TC_CR_90Device is capable of 90-degree character rotation.
 TC_CR_ANYDevice is capable of any character rotation.
 TC_SF_X_YINDEPDevice can scale independently in the x- and y-directions.
 TC_SA_DOUBLEDevice is capable of doubled character for scaling.
 TC_SA_INTEGERDevice uses integer multiples only for character scaling.
 TC_SA_CONTINDevice uses any multiples for exact character scaling.
 TC_EA_DOUBLEDevice can draw double-weight characters.
 TC_IA_ABLEDevice can italicize.
 TC_UA_ABLEDevice can underline.
 TC_SO_ABLEDevice can draw strikeouts.
 TC_RA_ABLEDevice can draw raster fonts.
 TC_VA_ABLEDevice can draw vector fonts.
 TC_RESERVEDReserved; must be zero.
 TC_SCROLLBLTDevice cannot scroll using a bit-block transfer. Note that this meaning may be the opposite of what you expect.
COLORMGMTCAPSWindows 2000/XP: Value that indicates the color management capabilities of the device.
 CM_CMYK_COLORDevice can accept CMYK color space ICC color profile.
 CM_DEVICE_ICMDevice can perform ICM on either the device driver or the device itself.
 CM_GAMMA_RAMPDevice supports GetDeviceGammaRamp and SetDeviceGammaRamp
 CM_NONEDevice does not support ICM.

Return Values

The return value specifies the value of the desired item.

When nIndex is BITSPIXEL and the device has 15bpp or 16bpp, the return value is 16.

Remarks

Do not call this method to get printer capabilities from an XPSDrv driver. Instead, use the DrvDeviceCapabilities function described in the Windows Driver Development Kit. value="

When nIndex is SHADEBLENDCAPS:

  • For a printer, GetDeviceCaps returns whatever the printer reports.
  • For a display device, all blending operations are available; besides SB_NONE, the only return values are SB_CONST_ALPHA and SB_PIXEL_ALPHA, which indicate whether these operations are accelerated.
  • On a multiple monitor system, if hdc is the desktop, then GetDeviceCaps returns the capabilities of the primary monitor.

GetDeviceCaps provides the following six indexes in place of printer escapes.

IndexPrinter escape replaced
PHYSICALWIDTHGETPHYSPAGESIZE
PHYSICALHEIGHTGETPHYSPAGESIZE
PHYSICALOFFSETXGETPRINTINGOFFSET
PHYSICALOFFSETYGETPHYSICALOFFSET
SCALINGFACTORXGETSCALINGFACTOR
SCALINGFACTORYGETSCALINGFACTOR

Example Code

For an example, see Preparing to Print.

Requirements

  Windows NT/2000/XP/Vista: Included in Windows NT 3.1 and later.
  Windows 95/98/Me: Included in Windows 95 and later.
  Header: Declared in Wingdi.h; include Windows.h.
  Library: Use Gdi32.lib.

See Also

Device Contexts Overview, Device Context Functions, CreateEnhMetaFile, CreateIC, DeviceCapabilities, GetDIBits, GetObjectType, SetDIBits, SetDIBitsToDevice, StretchBlt, StretchDIBits


Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker