Windows Interface Reference: DeviceContext structure

# DeviceContext

The DeviceContext structure contains functions and structures to create and operate on device contexts.

    structure DeviceContext:
      sig
        type BITMAP and HDC and HGDIOBJ and HWND and HRGN
        type LOGBRUSH = Brush.LOGBRUSH
        type LOGFONT = Font.LOGFONT
        type LOGPEN = Pen.LOGPEN
        type POINT = {x: int, y: int}

        type StockObjectType
        val ANSI_FIXED_FONT : StockObjectType
        val ANSI_VAR_FONT : StockObjectType
        val BLACK_BRUSH : StockObjectType
        val BLACK_PEN : StockObjectType
        val CLR_INVALID : StockObjectType
        val DEFAULT_PALETTE : StockObjectType
        val DEVICE_DEFAULT_FONT : StockObjectType
        val DKGRAY_BRUSH : StockObjectType
        val GRAY_BRUSH : StockObjectType
        val HOLLOW_BRUSH : StockObjectType
        val LTGRAY_BRUSH : StockObjectType
        val NULL_BRUSH : StockObjectType
        val NULL_PEN : StockObjectType
        val OEM_FIXED_FONT : StockObjectType
        val SYSTEM_FIXED_FONT : StockObjectType
        val SYSTEM_FONT : StockObjectType
        val WHITE_BRUSH : StockObjectType
        val WHITE_PEN : StockObjectType

        val GetStockObject : StockObjectType -> HGDIOBJ

        eqtype DeviceItem
        val ASPECTX : DeviceItem
        val ASPECTXY : DeviceItem
        val ASPECTY : DeviceItem
        val BITSPIXEL : DeviceItem
        val CLIPCAPS : DeviceItem
        val COLORRES : DeviceItem
        val CURVECAPS : DeviceItem
        val DRIVERVERSION : DeviceItem
        val HORZRES : DeviceItem
        val HORZSIZE : DeviceItem
        val LINECAPS : DeviceItem
        val LOGPIXELSX : DeviceItem
        val LOGPIXELSY : DeviceItem
        val NUMBRUSHES : DeviceItem
        val NUMCOLORS : DeviceItem
        val NUMFONTS : DeviceItem
        val NUMMARKERS : DeviceItem
        val NUMPENS : DeviceItem
        val NUMRESERVED : DeviceItem
        val PDEVICESIZE : DeviceItem
        val PHYSICALHEIGHT : DeviceItem
        val PHYSICALOFFSETX : DeviceItem
        val PHYSICALOFFSETY : DeviceItem
        val PHYSICALWIDTH : DeviceItem
        val PLANES : DeviceItem
        val POLYGONALCAPS : DeviceItem
        val RASTERCAPS : DeviceItem
        val SCALINGFACTORX : DeviceItem
        val SCALINGFACTORY : DeviceItem
        val SIZEPALETTE : DeviceItem
        val TECHNOLOGY : DeviceItem
        val TEXTCAPS : DeviceItem
        val VERTRES : DeviceItem
        val VERTSIZE : DeviceItem

        val GetDeviceCaps : HDC * DeviceItem -> int

       (* Results of various calls to GetDeviceCaps. *)
        val CC_CHORD : int
        val CC_CIRCLES : int
        val CC_ELLIPSES : int
        val CC_INTERIORS : int
        val CC_NONE : int
        val CC_PIE : int
        val CC_ROUNDRECT : int
        val CC_STYLED : int
        val CC_WIDE : int
        val CC_WIDESTYLED : int

        val CP_NONE : int
        val CP_RECTANGLE : int
        val CP_REGION : int

        val DT_CHARSTREAM : int
        val DT_DISPFILE : int
        val DT_METAFILE : int
        val DT_PLOTTER : int
        val DT_RASCAMERA : int
        val DT_RASDISPLAY : int
        val DT_RASPRINTER : int

        val LC_INTERIORS : int
        val LC_MARKER : int
        val LC_NONE : int
        val LC_POLYLINE : int
        val LC_POLYMARKER : int
        val LC_STYLED : int
        val LC_WIDE : int
        val LC_WIDESTYLED : int

        val PC_INTERIORS : int
        val PC_NONE : int
        val PC_PATHS : int
        val PC_POLYGON : int
        val PC_POLYPOLYGON : int
        val PC_RECTANGLE : int
        val PC_SCANLINE : int
        val PC_STYLED : int
        val PC_TRAPEZOID : int
        val PC_WIDE : int
        val PC_WIDESTYLED : int
        val PC_WINDPOLYGON : int

        val RC_BANDING : int
        val RC_BIGFONT : int
        val RC_BITBLT : int
        val RC_BITMAP64 : int
        val RC_DEVBITS : int
        val RC_DIBTODEV : int
        val RC_DI_BITMAP : int
        val RC_FLOODFILL : int
        val RC_GDI20_OUTPUT : int
        val RC_GDI20_STATE : int
        val RC_OP_DX_OUTPUT : int
        val RC_PALETTE : int
        val RC_SAVEBITMAP : int
        val RC_SCALING : int
        val RC_STRETCHBLT : int
        val RC_STRETCHDIB : int

        val TC_CP_STROKE : int
        val TC_CR_90 : int
        val TC_CR_ANY : int
        val TC_EA_DOUBLE : int
        val TC_IA_ABLE : int
        val TC_OP_CHARACTER : int
        val TC_OP_STROKE : int
        val TC_RA_ABLE : int
        val TC_RESERVED : int
        val TC_SA_CONTIN : int
        val TC_SA_DOUBLE : int
        val TC_SA_INTEGER : int
        val TC_SCROLLBLT : int
        val TC_SF_X_YINDEP : int
        val TC_SO_ABLE : int
        val TC_UA_ABLE : int
        val TC_VA_ABLE : int

        datatype DMColor = DMCOLOR_COLOR | DMCOLOR_MONOCHROME
        and DMDither =
              DMDITHER_COARSE
            | DMDITHER_FINE
            | DMDITHER_GRAYSCALE
            | DMDITHER_LINEART
            | DMDITHER_NONE
            | DMDITHER_OTHER of int
        and DMDuplex = DMDUP_HORIZONTAL | DMDUP_SIMPLEX | DMDUP_VERTICAL
        and DMICMIntent =
              DMICMINTENT_OTHER of int
            | DMICM_COLORMETRIC
            | DMICM_CONTRAST
            | DMICM_SATURATE
        and DMICMMethod =
              DMICMMETHOD_DEVICE
            | DMICMMETHOD_DRIVER
            | DMICMMETHOD_NONE
            | DMICMMETHOD_OTHER of int
            | DMICMMETHOD_SYSTEM
        and DMMedia =
              DMICMMEDIA_OTHER of int
            | DMMEDIA_GLOSSY
            | DMMEDIA_STANDARD
            | DMMEDIA_TRANSPARENCY
        and DMOrientation = DMORIENT_LANDSCAPE | DMORIENT_PORTRAIT
        and DMPaperSize =
              DMPAPER_10X11
            | DMPAPER_10X14
            | DMPAPER_11X17
            | DMPAPER_15X11
            | DMPAPER_9X11
            | DMPAPER_A2
            | DMPAPER_A3
            | DMPAPER_A3_EXTRA
            | DMPAPER_A3_EXTRA_TRANSVERSE
            | DMPAPER_A3_TRANSVERSE
            | DMPAPER_A4
            | DMPAPER_A4SMALL
            | DMPAPER_A4_EXTRA
            | DMPAPER_A4_PLUS
            | DMPAPER_A4_TRANSVERSE
            | DMPAPER_A5
            | DMPAPER_A5_EXTRA
            | DMPAPER_A5_TRANSVERSE
            | DMPAPER_A_PLUS
            | DMPAPER_B4
            | DMPAPER_B5
            | DMPAPER_B5_EXTRA
            | DMPAPER_B5_TRANSVERSE
            | DMPAPER_B_PLUS
            | DMPAPER_CSHEET
            | DMPAPER_DSHEET
            | DMPAPER_ENV_10
            | DMPAPER_ENV_11
            | DMPAPER_ENV_12
            | DMPAPER_ENV_14
            | DMPAPER_ENV_9
            | DMPAPER_ENV_B4
            | DMPAPER_ENV_B5
            | DMPAPER_ENV_B6
            | DMPAPER_ENV_C3
            | DMPAPER_ENV_C4
            | DMPAPER_ENV_C5
            | DMPAPER_ENV_C6
            | DMPAPER_ENV_C65
            | DMPAPER_ENV_DL
            | DMPAPER_ENV_INVITE
            | DMPAPER_ENV_ITALY
            | DMPAPER_ENV_MONARCH
            | DMPAPER_ENV_PERSONAL
            | DMPAPER_ESHEET
            | DMPAPER_EXECUTIVE
            | DMPAPER_FANFOLD_LGL_GERMAN
            | DMPAPER_FANFOLD_STD_GERMAN
            | DMPAPER_FANFOLD_US
            | DMPAPER_FOLIO
            | DMPAPER_ISO_B4
            | DMPAPER_JAPANESE_POSTCARD
            | DMPAPER_LEDGER
            | DMPAPER_LEGAL
            | DMPAPER_LEGAL_EXTRA
            | DMPAPER_LETTER
            | DMPAPER_LETTERSMALL
            | DMPAPER_LETTER_EXTRA
            | DMPAPER_LETTER_EXTRA_TRANSVERSE
            | DMPAPER_LETTER_PLUS
            | DMPAPER_LETTER_TRANSVERSE
            | DMPAPER_NOTE
            | DMPAPER_OTHER of int
            | DMPAPER_QUARTO
            | DMPAPER_RESERVED_48
            | DMPAPER_RESERVED_49
            | DMPAPER_STATEMENT
            | DMPAPER_TABLOID
            | DMPAPER_TABLOID_EXTRA
        and DMResolution =
              DMRES_DPI of int
            | DMRES_DRAFT
            | DMRES_HIGH
            | DMRES_LOW
            | DMRES_MEDIUM
        and DMSource =
              DMBIN_AUTO
            | DMBIN_CASSETTE
            | DMBIN_ENVELOPE
            | DMBIN_ENVMANUAL
            | DMBIN_FORMSOURCE
            | DMBIN_LARGECAPACITY
            | DMBIN_LARGEFMT
            | DMBIN_LOWER
            | DMBIN_MANUAL
            | DMBIN_MIDDLE
            | DMBIN_ONLYONE
            | DMBIN_SMALLFMT
            | DMBIN_TRACTOR
            | DMBIN_UPPER
            | DMSOURCE_OTHER of int
        and DMTrueType =
              DMTT_BITMAP
            | DMTT_DOWNLOAD
            | DMTT_DOWNLOAD_OUTLINE
            | DMTT_SUBDEV

        type DEVMODE = {
            deviceName: string,
            driverVersion: int,
            orientation: DMOrientation option,
            paperSize: DMPaperSize option,
            paperLength: int option,
            paperWidth: int option,
            scale: int option,
            copies: int option,
            defaultSource: DMSource option,
            printQuality: DMResolution option,
            color: DMColor option,
            duplex: DMDuplex option,
            yResolution: int option,
            ttOption: DMTrueType option,
            collate: bool option,
            formName: string option,
            logPixels: int option,
            bitsPerPixel: int option,
            pelsWidth: int option,
            pelsHeight: int option,
            displayFlags: int option, (* Apparently no longer used. *)
            displayFrequency: int option,
            icmMethod: DMICMMethod option,
            icmIntent: DMICMIntent option,
            mediaType: DMMedia option,
            ditherType: DMDither option,
            iccManufacturer: int option,
            iccModel: int option,
            panningWidth: int option,
            panningHeight: int option,
            driverPrivate: Word8Vector.vector
            }

        val CancelDC : HDC -> unit
        val CreateCompatibleDC : HDC -> HDC
        val CreateDC : string option * string option * string option * DEVMODE option -> HDC

        val DeleteDC : HDC -> unit
        val DeleteObject : HGDIOBJ -> unit

        datatype
          EnumObject =
              OBJ_BITMAP
            | OBJ_BRUSH
            | OBJ_DC
            | OBJ_ENHMETADC
            | OBJ_ENHMETAFILE
            | OBJ_EXTPEN
            | OBJ_FONT
            | OBJ_MEMDC
            | OBJ_METADC
            | OBJ_METAFILE
            | OBJ_PAL
            | OBJ_PEN
            | OBJ_REGION
        val GetCurrentObject : HDC * EnumObject -> HGDIOBJ
        val GetDC : HWND -> HDC

        datatype
          DeviceContextFlag =
              DCX_CACHE
            | DCX_CLIPCHILDREN
            | DCX_CLIPSIBLINGS
            | DCX_EXCLUDERGN
            | DCX_EXCLUDEUPDATE
            | DCX_INTERSECTRGN
            | DCX_INTERSECTUPDATE
            | DCX_LOCKWINDOWUPDATE
            | DCX_NORECOMPUTE
            | DCX_NORESETATTRS
            | DCX_PARENTCLIP
            | DCX_VALIDATE
            | DCX_WINDOW

        val GetDCEx : HWND * HRGN * DeviceContextFlag list -> HDC
        val GetDCOrgEx : HDC -> POINT

        datatype
          GetObject =
              GO_Bitmap of BITMAP
            | GO_Brush of LOGBRUSH
            | GO_Font of LOGFONT
            | GO_Palette of int
            | GO_Pen of LOGPEN

        val GetObject : HGDIOBJ -> GetObject
        val GetObjectType : HGDIOBJ -> EnumObject
        val ReleaseDC : HWND * HDC -> bool
        val ResetDC : HDC * DEVMODE -> HDC
        val RestoreDC : HDC * int -> unit
        val SaveDC : HDC -> int
        val SelectObject : HDC * HGDIOBJ -> HGDIOBJ

        type DEVNAMES = {driver: string, device: string, output: string, default: bool}

      end