/**
 * Windows API header module
 *
 * Translated from MinGW Windows headers
 *
 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
 * Source: $(DRUNTIMESRC core/sys/windows/_wingdi.d)
 */
module core.sys.windows.wingdi;
version (Windows):

version (ANSI) {} else version = Unicode;
pragma(lib, "gdi32");

// FIXME: clean up Windows version support

import core.sys.windows.w32api, core.sys.windows.windef, core.sys.windows.winver;

// BITMAPINFOHEADER.biCompression
enum : DWORD {
    BI_RGB = 0,
    BI_RLE8,
    BI_RLE4,
    BI_BITFIELDS,
    BI_JPEG,
    BI_PNG
}

// ---
// COLORADJUSTMENT -- only for NT 3.1+, Win2000+
enum WORD
    CA_NEGATIVE   = 1,
    CA_LOG_FILTER = 2;

// COLORADJUSTMENT
enum : WORD  {
    ILLUMINANT_DEVICE_DEFAULT = 0,
    ILLUMINANT_A,
    ILLUMINANT_B,
    ILLUMINANT_C,
    ILLUMINANT_D50,
    ILLUMINANT_D55,
    ILLUMINANT_D65,
    ILLUMINANT_D75,
    ILLUMINANT_F2,
    ILLUMINANT_MAX_INDEX   = ILLUMINANT_F2,
    ILLUMINANT_TUNGSTEN    = ILLUMINANT_A,
    ILLUMINANT_DAYLIGHT    = ILLUMINANT_C,
    ILLUMINANT_FLUORESCENT = ILLUMINANT_F2,
    ILLUMINANT_NTSC        = ILLUMINANT_C
}

enum {
    RGB_GAMMA_MIN       = 2500,
    RGB_GAMMA_MAX       = 65000,
    REFERENCE_WHITE_MIN = 6000,
    REFERENCE_WHITE_MAX = 10000,
    REFERENCE_BLACK_MIN = 0,
    REFERENCE_BLACK_MAX = 4000,
    COLOR_ADJ_MIN       = -100,
    COLOR_ADJ_MAX       = 100,
}
//---

/* FIXME: move to core.sys.windows.winuser ? */
// DrawIconEx()
enum : UINT {
    DI_MASK        = 1,
    DI_IMAGE       = 2,
    DI_NORMAL      = 3,
    DI_COMPAT      = 4,
    DI_DEFAULTSIZE = 8
}

// DOCINFO
enum : DWORD {
    DI_APPBANDING = 1,
    DI_ROPS_READ_DESTINATION = 2,
}

// ENHMETAHEADER
enum : DWORD {
    EMR_HEADER = 1,
    EMR_POLYBEZIER,
    EMR_POLYGON,
    EMR_POLYLINE,
    EMR_POLYBEZIERTO,
    EMR_POLYLINETO,
    EMR_POLYPOLYLINE,
    EMR_POLYPOLYGON,
    EMR_SETWINDOWEXTEX,
    EMR_SETWINDOWORGEX,
    EMR_SETVIEWPORTEXTEX,
    EMR_SETVIEWPORTORGEX,
    EMR_SETBRUSHORGEX,
    EMR_EOF,
    EMR_SETPIXELV,
    EMR_SETMAPPERFLAGS,
    EMR_SETMAPMODE,
    EMR_SETBKMODE,
    EMR_SETPOLYFILLMODE,
    EMR_SETROP2,
    EMR_SETSTRETCHBLTMODE,
    EMR_SETTEXTALIGN,
    EMR_SETCOLORADJUSTMENT,
    EMR_SETTEXTCOLOR,
    EMR_SETBKCOLOR,
    EMR_OFFSETCLIPRGN,
    EMR_MOVETOEX,
    EMR_SETMETARGN,
    EMR_EXCLUDECLIPRECT,
    EMR_INTERSECTCLIPRECT,
    EMR_SCALEVIEWPORTEXTEX,
    EMR_SCALEWINDOWEXTEX,
    EMR_SAVEDC,
    EMR_RESTOREDC,
    EMR_SETWORLDTRANSFORM,
    EMR_MODIFYWORLDTRANSFORM,
    EMR_SELECTOBJECT,
    EMR_CREATEPEN,
    EMR_CREATEBRUSHINDIRECT,
    EMR_DELETEOBJECT,
    EMR_ANGLEARC,
    EMR_ELLIPSE,
    EMR_RECTANGLE,
    EMR_ROUNDRECT,
    EMR_ARC,
    EMR_CHORD,
    EMR_PIE,
    EMR_SELECTPALETTE,
    EMR_CREATEPALETTE,
    EMR_SETPALETTEENTRIES,
    EMR_RESIZEPALETTE,
    EMR_REALIZEPALETTE,
    EMR_EXTFLOODFILL,
    EMR_LINETO,
    EMR_ARCTO,
    EMR_POLYDRAW,
    EMR_SETARCDIRECTION,
    EMR_SETMITERLIMIT,
    EMR_BEGINPATH,
    EMR_ENDPATH,
    EMR_CLOSEFIGURE,
    EMR_FILLPATH,
    EMR_STROKEANDFILLPATH,
    EMR_STROKEPATH,
    EMR_FLATTENPATH,
    EMR_WIDENPATH,
    EMR_SELECTCLIPPATH,
    EMR_ABORTPATH, // 68
    // reserved 69
    EMR_GDICOMMENT = 70,
    EMR_FILLRGN,
    EMR_FRAMERGN,
    EMR_INVERTRGN,
    EMR_PAINTRGN,
    EMR_EXTSELECTCLIPRGN,
    EMR_BITBLT,
    EMR_STRETCHBLT,
    EMR_MASKBLT,
    EMR_PLGBLT,
    EMR_SETDIBITSTODEVICE,
    EMR_STRETCHDIBITS,
    EMR_EXTCREATEFONTINDIRECTW,
    EMR_EXTTEXTOUTA,
    EMR_EXTTEXTOUTW,
    EMR_POLYBEZIER16,
    EMR_POLYGON16,
    EMR_POLYLINE16,
    EMR_POLYBEZIERTO16,
    EMR_POLYLINETO16,
    EMR_POLYPOLYLINE16,
    EMR_POLYPOLYGON16,
    EMR_POLYDRAW16,
    EMR_CREATEMONOBRUSH,
    EMR_CREATEDIBPATTERNBRUSHPT,
    EMR_EXTCREATEPEN,
    EMR_POLYTEXTOUTA,
    EMR_POLYTEXTOUTW, // 97
    EMR_SETICMMODE,
    EMR_CREATECOLORSPACE,
    EMR_SETCOLORSPACE,
    EMR_DELETECOLORSPACE,
    EMR_GLSRECORD,
    EMR_GLSBOUNDEDRECORD,
    EMR_PIXELFORMAT, // = 104
    // reserved 105 - 110
    EMR_COLORCORRECTPALETTE = 111,
    EMR_SETICMPROFILEA,
    EMR_SETICMPROFILEW,
    EMR_ALPHABLEND,
    EMR_SETLAYOUT,
    EMR_TRANSPARENTBLT, // 116
    // reserved 117
    EMR_GRADIENTFILL = 118,
    // reserved 119, 120
    EMR_COLORMATCHTOTARGETW = 121,
    EMR_CREATECOLORSPACEW // 122
}

enum EMR_MIN = EMR_HEADER;

static if (_WIN32_WINNT >= 0x500) {
enum EMR_MAX = EMR_CREATECOLORSPACEW;
} else {
enum EMR_MAX = EMR_PIXELFORMAT;
}

// ENHMETAHEADER.dSignature, ENHMETAHEADER3.dSignature,
// EMRFORMAT.dSignature
enum : DWORD {
    ENHMETA_SIGNATURE = 1179469088,
    EPS_SIGNATURE     = 0x46535045
}

static if (_WIN32_WINNT >= 0x500) {
    // AddFontResourceEx()
    enum : DWORD {
        FR_PRIVATE  = 0x10,
        FR_NOT_ENUM = 0x20
    }
}

enum {
    META_SAVEDC                = 0x1E,
    META_REALIZEPALETTE        = 0x35,
    META_SETPALENTRIES         = 0x37,
    META_CREATEPALETTE         = 0xf7,
    META_SETBKMODE             = 0x102,
    META_SETMAPMODE            = 0x103,
    META_SETROP2               = 0x104,
    META_SETRELABS             = 0x105,
    META_SETPOLYFILLMODE       = 0x106,
    META_SETSTRETCHBLTMODE     = 0x107,
    META_SETTEXTCHAREXTRA      = 0x108,
    META_RESTOREDC             = 0x127,
    META_INVERTREGION          = 0x12A,
    META_PAINTREGION           = 0x12B,
    META_SELECTCLIPREGION      = 0x12C,
    META_SELECTOBJECT          = 0x12D,
    META_SETTEXTALIGN          = 0x12E,
    META_RESIZEPALETTE         = 0x139,
    META_DIBCREATEPATTERNBRUSH = 0x142,
    META_SETLAYOUT             = 0x149,
    META_DELETEOBJECT          = 0x1F0,
    META_CREATEPATTERNBRUSH    = 0x1F9,
    META_SETBKCOLOR            = 0x201,
    META_SETTEXTCOLOR          = 0x209,
    META_SETTEXTJUSTIFICATION  = 0x20A,
    META_SETWINDOWORG          = 0x20B,
    META_SETWINDOWEXT          = 0x20C,
    META_SETVIEWPORTORG        = 0x20D,
    META_SETVIEWPORTEXT        = 0x20E,
    META_OFFSETWINDOWORG       = 0x20F,
    META_OFFSETVIEWPORTORG     = 0x211,
    META_LINETO                = 0x213,
    META_MOVETO                = 0x214,
    META_OFFSETCLIPRGN         = 0x220,
    META_FILLREGION            = 0x228,
    META_SETMAPPERFLAGS        = 0x231,
    META_SELECTPALETTE         = 0x234,
    META_CREATEPENINDIRECT     = 0x2FA,
    META_CREATEFONTINDIRECT    = 0x2FB,
    META_CREATEBRUSHINDIRECT   = 0x2FC,
    META_POLYGON               = 0x324,
    META_POLYLINE              = 0x325,
    META_SCALEWINDOWEXT        = 0x410,
    META_SCALEVIEWPORTEXT      = 0x412,
    META_EXCLUDECLIPRECT       = 0x415,
    META_INTERSECTCLIPRECT     = 0x416,
    META_ELLIPSE               = 0x418,
    META_FLOODFILL             = 0x419,
    META_RECTANGLE             = 0x41B,
    META_SETPIXEL              = 0x41F,
    META_FRAMEREGION           = 0x429,
    META_ANIMATEPALETTE        = 0x436,
    META_TEXTOUT               = 0x521,
    META_POLYPOLYGON           = 0x538,
    META_EXTFLOODFILL          = 0x548,
    META_ROUNDRECT             = 0x61C,
    META_PATBLT                = 0x61D,
    META_ESCAPE                = 0x626,
    META_CREATEREGION          = 0x6FF,
    META_ARC                   = 0x817,
    META_PIE                   = 0x81A,
    META_CHORD                 = 0x830,
    META_BITBLT                = 0x922,
    META_DIBBITBLT             = 0x940,
    META_EXTTEXTOUT            = 0xA32,
    META_STRETCHBLT            = 0xB23,
    META_DIBSTRETCHBLT         = 0xB41,
    META_SETDIBTODEV           = 0xD33,
    META_STRETCHDIB            = 0xF43
}

// EMRPOLYDRAW
enum : BYTE {
    PT_CLOSEFIGURE = 1,
    PT_LINETO      = 2,
    PT_BEZIERTO    = 4,
    PT_MOVETO      = 6
}

// ----
// PIXELFORMATDESCRIPTOR.iPixelType
enum : BYTE {
    PFD_TYPE_RGBA       = 0,
    PFD_TYPE_COLORINDEX = 1
}

//deprecated {
// PIXELFORMATDESCRIPTOR.
enum byte
    PFD_MAIN_PLANE     = 0,
    PFD_OVERLAY_PLANE  = 1,
    PFD_UNDERLAY_PLANE = -1;
//}
// PIXELFORMATDESCRIPTOR.dwFlags
enum DWORD
    PFD_DOUBLEBUFFER          = 0x00000001,
    PFD_STEREO                = 0x00000002,
    PFD_DRAW_TO_WINDOW        = 0x00000004,
    PFD_DRAW_TO_BITMAP        = 0x00000008,
    PFD_SUPPORT_GDI           = 0x00000010,
    PFD_SUPPORT_OPENGL        = 0x00000020,
    PFD_GENERIC_FORMAT        = 0x00000040,
    PFD_NEED_PALETTE          = 0x00000080,
    PFD_NEED_SYSTEM_PALETTE   = 0x00000100,
    PFD_SWAP_EXCHANGE         = 0x00000200,
    PFD_SWAP_COPY             = 0x00000400,
    PFD_SWAP_LAYER_BUFFERS    = 0x00000800,
    PFD_GENERIC_ACCELERATED   = 0x00001000,
    PFD_SUPPORT_DIRECTDRAW    = 0x00002000,
    PFD_DIRECT3D_ACCELERATED  = 0x00004000,
    PFD_SUPPORT_COMPOSITION   = 0x00008000,
    /* PIXELFORMATDESCRIPTOR flags for use in ChoosePixelFormat only */
    PFD_DEPTH_DONTCARE        = 0x20000000,
    PFD_DOUBLEBUFFER_DONTCARE = 0x40000000,
    PFD_STEREO_DONTCARE       = 0x80000000;

// ----

enum DWORD
    BLACKNESS   = 0x000042,
    NOTSRCERASE = 0x1100A6,
    NOTSRCCOPY  = 0x330008,
    SRCERASE    = 0x440328,
    DSTINVERT   = 0x550009,
    PATINVERT   = 0x5A0049,
    SRCINVERT   = 0x660046,
    SRCAND      = 0x8800C6,
    MERGEPAINT  = 0xBB0226,
    MERGECOPY   = 0xC000CA,
    SRCCOPY     = 0xCC0020,
    SRCPAINT    = 0xEE0086,
    PATCOPY     = 0xF00021,
    PATPAINT    = 0xFB0A09,
    WHITENESS   = 0xFF0062;
static if (_WIN32_WINNT >= 0x500) {
enum DWORD
        NOMIRRORBITMAP = 0x80000000,
        CAPTUREBLT     = 0x40000000;
}

// GetROP2(), SetROP2()
enum : int {
    R2_BLACK       = 1,
    R2_NOTMERGEPEN = 2,
    R2_MASKNOTPEN  = 3,
    R2_NOTCOPYPEN  = 4,
    R2_MASKPENNOT  = 5,
    R2_NOT         = 6,
    R2_XORPEN      = 7,
    R2_NOTMASKPEN  = 8,
    R2_MASKPEN     = 9,
    R2_NOTXORPEN   = 10,
    R2_NOP         = 11,
    R2_MERGENOTPEN = 12,
    R2_COPYPEN     = 13,
    R2_MERGEPENNOT = 14,
    R2_MERGEPEN    = 15,
    R2_WHITE       = 16
}

enum R2_LAST = R2_WHITE;

// CheckColorsInGamut()
enum ubyte
    CM_IN_GAMUT     = 0,
    CM_OUT_OF_GAMUT = 255;

/* UpdateICMRegKey Constants               */
enum int
    ICM_ADDPROFILE = 1,
    ICM_DELETEPROFILE = 2,
    ICM_QUERYPROFILE = 3,
    ICM_SETDEFAULTPROFILE = 4,
    ICM_REGISTERICMATCHER = 5,
    ICM_UNREGISTERICMATCHER = 6,
    ICM_QUERYMATCH = 7;

enum : int {
    RGN_AND  = 1,
    RGN_OR   = 2,
    RGN_XOR  = 3,
    RGN_DIFF = 4,
    RGN_COPY = 5
}

enum RGN_MIN = RGN_AND;
enum RGN_MAX = RGN_COPY;

// Return values for CombineRgn()
enum {
    NULLREGION    = 1,
    SIMPLEREGION  = 2,
    COMPLEXREGION = 3
}

enum ERROR = 0;
alias RGN_ERROR = ERROR;

// CreateDIBitmap()
enum DWORD CBM_INIT = 4;

// CreateDIBitmap()
enum : UINT {
    DIB_RGB_COLORS = 0,
    DIB_PAL_COLORS = 1
}

// ---
//  Values for LOGFONT and CreateFont()

// FIXME: For D, replace with lfFaceName.length()
enum LF_FACESIZE     = 32;
enum LF_FULLFACESIZE = 64;

// FIXME: Not needed for D, only EXTLOGFONT
enum ELF_VENDOR_SIZE = 4;

// ???
enum ELF_VERSION = 0;
enum ELF_CULTURE_LATIN = 0;

// LOGFONT.lfWeight
enum LONG
    FW_DONTCARE   = 0,
    FW_THIN       = 100,
    FW_EXTRALIGHT = 200,
    FW_ULTRALIGHT = FW_EXTRALIGHT,
    FW_LIGHT      = 300,
    FW_NORMAL     = 400,
    FW_REGULAR    = FW_NORMAL,
    FW_MEDIUM     = 500,
    FW_SEMIBOLD   = 600,
    FW_DEMIBOLD   = FW_SEMIBOLD,
    FW_BOLD       = 700,
    FW_EXTRABOLD  = 800,
    FW_ULTRABOLD  = FW_EXTRABOLD,
    FW_HEAVY      = 900,
    FW_BLACK      = FW_HEAVY;

// LOGFONT.lfCharSet
enum : DWORD {
    ANSI_CHARSET        = 0,
    DEFAULT_CHARSET     = 1,
    SYMBOL_CHARSET      = 2,
    MAC_CHARSET         = 77,
    SHIFTJIS_CHARSET    = 128,
    HANGEUL_CHARSET     = 129,
    HANGUL_CHARSET      = 129,
    JOHAB_CHARSET       = 130,
    GB2312_CHARSET      = 134,
    CHINESEBIG5_CHARSET = 136,
    GREEK_CHARSET       = 161,
    TURKISH_CHARSET     = 162,
    VIETNAMESE_CHARSET  = 163,
    HEBREW_CHARSET      = 177,
    ARABIC_CHARSET      = 178,
    BALTIC_CHARSET      = 186,
    RUSSIAN_CHARSET     = 204,
    THAI_CHARSET        = 222,
    EASTEUROPE_CHARSET  = 238,
    OEM_CHARSET         = 255
}

// LOGFONT.lfOutPrecision
enum : BYTE {
    OUT_DEFAULT_PRECIS = 0,
    OUT_STRING_PRECIS,
    OUT_CHARACTER_PRECIS,
    OUT_STROKE_PRECIS,
    OUT_TT_PRECIS,
    OUT_DEVICE_PRECIS,
    OUT_RASTER_PRECIS,
    OUT_TT_ONLY_PRECIS,
    OUT_OUTLINE_PRECIS,
    OUT_SCREEN_OUTLINE_PRECIS,
    OUT_PS_ONLY_PRECIS, // 10
}

// LOGFONT.lfClipPrecision
enum : BYTE  {
    CLIP_DEFAULT_PRECIS   = 0,
    CLIP_CHARACTER_PRECIS = 1,
    CLIP_STROKE_PRECIS    = 2,
    CLIP_MASK             = 15,
    CLIP_LH_ANGLES        = 16,
    CLIP_TT_ALWAYS        = 32,
    CLIP_DFA_DISABLE      = 64,
    CLIP_EMBEDDED         = 128
}

// LOGFONT.lfQuality
enum : BYTE {
    DEFAULT_QUALITY = 0,
    DRAFT_QUALITY,
    PROOF_QUALITY,
    NONANTIALIASED_QUALITY,
    ANTIALIASED_QUALITY
}

// LOGFONT.lfPitchAndFamily

enum BYTE
    DEFAULT_PITCH  = 0,
    FIXED_PITCH    = 1,
    VARIABLE_PITCH = 2,
    MONO_FONT      = 8,
    FF_DONTCARE    = 0,
    FF_ROMAN       = 16,
    FF_SWISS       = 32,
    FF_SCRIPT      = 64,
    FF_MODERN      = 48,
    FF_DECORATIVE  = 80;

// ----
// Enums for the PANOSE struct

enum PANOSE_COUNT=10;

enum {
    PAN_FAMILYTYPE_INDEX = 0,
    PAN_SERIFSTYLE_INDEX,
    PAN_WEIGHT_INDEX,
    PAN_PROPORTION_INDEX,
    PAN_CONTRAST_INDEX,
    PAN_STROKEVARIATION_INDEX,
    PAN_ARMSTYLE_INDEX,
    PAN_LETTERFORM_INDEX,
    PAN_MIDLINE_INDEX,
    PAN_XHEIGHT_INDEX
}

enum PAN_CULTURE_LATIN=0;

// NOTE: the first two values (PAN_ANY and PAN_NO_FIT) apply to all these enums!
enum : BYTE {
    PAN_ANY    = 0,
    PAN_NO_FIT = 1,
}

enum : BYTE {
    PAN_FAMILY_TEXT_DISPLAY = 2,
    PAN_FAMILY_SCRIPT,
    PAN_FAMILY_DECORATIVE,
    PAN_FAMILY_PICTORIAL
}
enum : BYTE {
    PAN_SERIF_COVE = 2,
    PAN_SERIF_OBTUSE_COVE,
    PAN_SERIF_SQUARE_COVE,
    PAN_SERIF_OBTUSE_SQUARE_COVE,
    PAN_SERIF_SQUARE,
    PAN_SERIF_THIN,
    PAN_SERIF_BONE,
    PAN_SERIF_EXAGGERATED,
    PAN_SERIF_TRIANGLE,
    PAN_SERIF_NORMAL_SANS,
    PAN_SERIF_OBTUSE_SANS,
    PAN_SERIF_PERP_SANS,
    PAN_SERIF_FLARED,
    PAN_SERIF_ROUNDED
}

enum : BYTE {
    PAN_WEIGHT_VERY_LIGHT = 2,
    PAN_WEIGHT_LIGHT,
    PAN_WEIGHT_THIN,
    PAN_WEIGHT_BOOK,
    PAN_WEIGHT_MEDIUM,
    PAN_WEIGHT_DEMI,
    PAN_WEIGHT_BOLD,
    PAN_WEIGHT_HEAVY,
    PAN_WEIGHT_BLACK,
    PAN_WEIGHT_NORD
}

enum : BYTE {
    PAN_PROP_OLD_STYLE = 2,
    PAN_PROP_MODERN,
    PAN_PROP_EVEN_WIDTH,
    PAN_PROP_EXPANDED,
    PAN_PROP_CONDENSED,
    PAN_PROP_VERY_EXPANDED,
    PAN_PROP_VERY_CONDENSED,
    PAN_PROP_MONOSPACED
}

enum : BYTE {
    PAN_CONTRAST_NONE = 2,
    PAN_CONTRAST_VERY_LOW,
    PAN_CONTRAST_LOW,
    PAN_CONTRAST_MEDIUM_LOW,
    PAN_CONTRAST_MEDIUM,
    PAN_CONTRAST_MEDIUM_HIGH,
    PAN_CONTRAST_HIGH,
    PAN_CONTRAST_VERY_HIGH
}

// PANOSE.bStrokeVariation
enum : BYTE {
    PAN_STROKE_GRADUAL_DIAG = 2,
    PAN_STROKE_GRADUAL_TRAN,
    PAN_STROKE_GRADUAL_VERT,
    PAN_STROKE_GRADUAL_HORZ,
    PAN_STROKE_RAPID_VERT,
    PAN_STROKE_RAPID_HORZ,
    PAN_STROKE_INSTANT_VERT
}

// PANOSE.bArmStyle
enum : BYTE {
    PAN_STRAIGHT_ARMS_HORZ = 2,
    PAN_STRAIGHT_ARMS_WEDGE,
    PAN_STRAIGHT_ARMS_VERT,
    PAN_STRAIGHT_ARMS_SINGLE_SERIF,
    PAN_STRAIGHT_ARMS_DOUBLE_SERIF,
    PAN_BENT_ARMS_HORZ,
    PAN_BENT_ARMS_WEDGE,
    PAN_BENT_ARMS_VERT,
    PAN_BENT_ARMS_SINGLE_SERIF,
    PAN_BENT_ARMS_DOUBLE_SERIF
}

// PANOSE.bLetterForm
enum : BYTE {
    PAN_LETT_NORMAL_CONTACT = 2,
    PAN_LETT_NORMAL_WEIGHTED,
    PAN_LETT_NORMAL_BOXED,
    PAN_LETT_NORMAL_FLATTENED,
    PAN_LETT_NORMAL_ROUNDED,
    PAN_LETT_NORMAL_OFF_CENTER,
    PAN_LETT_NORMAL_SQUARE,
    PAN_LETT_OBLIQUE_CONTACT,
    PAN_LETT_OBLIQUE_WEIGHTED,
    PAN_LETT_OBLIQUE_BOXED,
    PAN_LETT_OBLIQUE_FLATTENED,
    PAN_LETT_OBLIQUE_ROUNDED,
    PAN_LETT_OBLIQUE_OFF_CENTER,
    PAN_LETT_OBLIQUE_SQUARE
}

// PANOSE.bMidLine
enum : BYTE {
    PAN_MIDLINE_STANDARD_TRIMMED = 2,
    PAN_MIDLINE_STANDARD_POINTED,
    PAN_MIDLINE_STANDARD_SERIFED,
    PAN_MIDLINE_HIGH_TRIMMED,
    PAN_MIDLINE_HIGH_POINTED,
    PAN_MIDLINE_HIGH_SERIFED,
    PAN_MIDLINE_CONSTANT_TRIMMED,
    PAN_MIDLINE_CONSTANT_POINTED,
    PAN_MIDLINE_CONSTANT_SERIFED,
    PAN_MIDLINE_LOW_TRIMMED,
    PAN_MIDLINE_LOW_POINTED,
    PAN_MIDLINE_LOW_SERIFED
}

// PANOSE.bXHeight
enum : BYTE {
    PAN_XHEIGHT_CONSTANT_SMALL = 2,
    PAN_XHEIGHT_CONSTANT_STD,
    PAN_XHEIGHT_CONSTANT_LARGE,
    PAN_XHEIGHT_DUCKING_SMALL,
    PAN_XHEIGHT_DUCKING_STD,
    PAN_XHEIGHT_DUCKING_LARGE
}

// ----
// ???
enum FS_LATIN1      = 0x00000001;
enum FS_LATIN2      = 0x00000002;
enum FS_CYRILLIC    = 0x00000004;
enum FS_GREEK       = 0x00000008;
enum FS_TURKISH     = 0x00000010;
enum FS_HEBREW      = 0x00000020;
enum FS_ARABIC      = 0x00000040;
enum FS_BALTIC      = 0x00000080;
enum FS_VIETNAMESE  = 0x00000100;
enum FS_THAI        = 0x00010000;
enum FS_JISJAPAN    = 0x00020000;
enum FS_CHINESESIMP = 0x00040000;
enum FS_WANSUNG     = 0x00080000;
enum FS_CHINESETRAD = 0x00100000;
enum FS_JOHAB       = 0x00200000;
enum FS_SYMBOL      = 0x80000000;

// ----
// Poly Fill Mode
enum : int {
    ALTERNATE = 1,
    WINDING = 2
}
enum int POLYFILL_LAST = WINDING;

//---
// LOGBRUSH
enum : LONG {
    HS_HORIZONTAL = 0,
    HS_VERTICAL,
    HS_FDIAGONAL,
    HS_BDIAGONAL,
    HS_CROSS,
    HS_DIAGCROSS
}

//LOGBRUSH.lbStyle
enum : UINT {
    BS_SOLID = 0,
    BS_NULL  = 1,
    BS_HOLLOW = BS_NULL,
    BS_HATCHED,
    BS_PATTERN,
    BS_INDEXED,
    BS_DIBPATTERN,
    BS_DIBPATTERNPT,
    BS_PATTERN8X8,
    BS_DIBPATTERN8X8,
    BS_MONOPATTERN,
}
//-----
// EXTLOGPEN, ExtCreatePen()

// EXTLOGPEN.elpPenStyle
enum : DWORD {
    PS_SOLID       = 0,
    PS_DASH        = 1,
    PS_DOT         = 2,
    PS_DASHDOT     = 3,
    PS_DASHDOTDOT  = 4,
    PS_NULL        = 5,
    PS_INSIDEFRAME = 6,
    PS_USERSTYLE   = 7,
    PS_ALTERNATE   = 8,
    PS_STYLE_MASK  = 15,
}

enum : DWORD {
    PS_COSMETIC      = 0x00000000,
    PS_GEOMETRIC     = 0x00010000,
    PS_TYPE_MASK     = 0x000F0000,
}
enum : DWORD {
    PS_ENDCAP_ROUND  = 0x00000000,
    PS_ENDCAP_SQUARE = 0x00000100,
    PS_ENDCAP_FLAT   = 0x00000200,
    PS_ENDCAP_MASK   = 0x00000F00,
}
enum : DWORD {
    PS_JOIN_ROUND    = 0x00000000,
    PS_JOIN_BEVEL    = 0x00001000,
    PS_JOIN_MITER    = 0x00002000,
    PS_JOIN_MASK     = 0x0000F000,
}

// ---
// DeviceCapabilities()

enum : WORD {
    DC_FIELDS = 1,
    DC_PAPERS,
    DC_PAPERSIZE,
    DC_MINEXTENT,
    DC_MAXEXTENT,
    DC_BINS,
    DC_DUPLEX,
    DC_SIZE,
    DC_EXTRA,
    DC_VERSION,
    DC_DRIVER,
    DC_BINNAMES,
    DC_ENUMRESOLUTIONS,
    DC_FILEDEPENDENCIES,
    DC_TRUETYPE,
    DC_PAPERNAMES,
    DC_ORIENTATION,
    DC_COPIES,
    DC_BINADJUST,
    DC_EMF_COMPLIANT,
    DC_DATATYPE_PRODUCED,
    DC_COLLATE,
    DC_MANUFACTURER,
    DC_MODEL,
}

static if (_WIN32_WINNT >= 0x500) {
    enum {
        DC_PERSONALITY = 25,
        DC_PRINTRATE = 26,
        DC_PRINTRATEUNIT = 27,
        DC_PRINTERMEM = 28,
        DC_MEDIAREADY = 29,
        DC_STAPLE = 30,
        DC_PRINTRATEPPM = 31,
        DC_COLORDEVICE = 32,
        DC_NUP = 33,
        DC_MEDIATYPENAMES = 34,
        DC_MEDIATYPES = 35,
    }
    enum {
        PRINTRATEUNIT_PPM = 1,
        PRINTRATEUNIT_CPS = 2,
        PRINTRATEUNIT_LPM = 3,
        PRINTRATEUNIT_IPM = 4,
    }
}


// return from DC_TRUETYPE
enum DWORD
    DCTT_BITMAP           = 1,
    DCTT_DOWNLOAD         = 2,
    DCTT_SUBDEV           = 4,
    DCTT_DOWNLOAD_OUTLINE = 8;

// return from DC_BINADJUST
enum : DWORD {
    DCBA_FACEUPNONE     = 0x0000,
    DCBA_FACEUPCENTER   = 0x0001,
    DCBA_FACEUPLEFT     = 0x0002,
    DCBA_FACEUPRIGHT    = 0x0003,
    DCBA_FACEDOWNNONE   = 0x0100,
    DCBA_FACEDOWNCENTER = 0x0101,
    DCBA_FACEDOWNLEFT   = 0x0102,
    DCBA_FACEDOWNRIGHT  = 0x0103,
}
//---

enum FLOODFILLBORDER  = 0;
enum FLOODFILLSURFACE = 1;

// ExtTextOut()
enum UINT
    ETO_OPAQUE         = 0x0002,
    ETO_CLIPPED        = 0x0004,
    ETO_GLYPH_INDEX    = 0x0010,
    ETO_RTLREADING     = 0x0080,
    ETO_NUMERICSLOCAL  = 0x0400,
    ETO_NUMERICSLATIN  = 0x0800,
    ETO_IGNORELANGUAGE = 0x1000;
static if (_WIN32_WINNT >= 0x500) {
enum UINT
        ETO_PDY = 0x2000;
}

// GdiComment()
enum {
    GDICOMMENT_BEGINGROUP       = 0x00000002,
    GDICOMMENT_ENDGROUP         = 0x00000003,
    GDICOMMENT_UNICODE_STRING   = 0x00000040,
    GDICOMMENT_UNICODE_END      = 0x00000080,
    GDICOMMENT_MULTIFORMATS     = 0x40000004,
    GDICOMMENT_IDENTIFIER       = 0x43494447,
    GDICOMMENT_WINDOWS_METAFILE = 0x80000001,
}

// Get/SetArcDirection()
enum : int {
    AD_COUNTERCLOCKWISE = 1,
    AD_CLOCKWISE        = 2
}

enum RDH_RECTANGLES = 1;

// GCPRESULTS.lpClass
enum {
    GCPCLASS_LATIN  = 1,
    GCPCLASS_HEBREW = 2,
    GCPCLASS_ARABIC = 2,
    GCPCLASS_NEUTRAL,
    GCPCLASS_LOCALNUMBER,
    GCPCLASS_LATINNUMBER,
    GCPCLASS_LATINNUMERICTERMINATOR,
    GCPCLASS_LATINNUMERICSEPARATOR,
    GCPCLASS_NUMERICSEPARATOR, // = 8,
    GCPCLASS_POSTBOUNDRTL = 16,
    GCPCLASS_POSTBOUNDLTR = 32,
    GCPCLASS_PREBOUNDRTL  = 64,
    GCPCLASS_PREBOUNDLTR  = 128,
    GCPGLYPH_LINKAFTER    = 0x4000,
    GCPGLYPH_LINKBEFORE   = 0x8000
}

// GetBoundsRect(), SetBoundsRect()
enum UINT
    DCB_RESET      = 1,
    DCB_ACCUMULATE = 2,
    DCB_SET        = DCB_RESET | DCB_ACCUMULATE,
    DCB_ENABLE     = 4,
    DCB_DISABLE    = 8,
    DCB_DIRTY      = DCB_ACCUMULATE;

//---
// GetObjectType()
enum : DWORD {
    OBJ_PEN = 1,
    OBJ_BRUSH,
    OBJ_DC,
    OBJ_METADC,
    OBJ_PAL,
    OBJ_FONT,
    OBJ_BITMAP,
    OBJ_REGION,
    OBJ_METAFILE,
    OBJ_MEMDC,
    OBJ_EXTPEN,
    OBJ_ENHMETADC,
    OBJ_ENHMETAFILE,
    OBJ_COLORSPACE,
}

//---------------------
// Capabilities for GetDeviceCaps(dc, xxx)

enum : int {
    DRIVERVERSION   = 0,
    TECHNOLOGY      = 2,
    HORZSIZE        = 4,
    VERTSIZE        = 6,
    HORZRES         = 8,
    VERTRES         = 10,
    BITSPIXEL       = 12,
    PLANES          = 14,
    NUMBRUSHES      = 16,
    NUMPENS         = 18,
    NUMMARKERS      = 20,
    NUMFONTS        = 22,
    NUMCOLORS       = 24,
    PDEVICESIZE     = 26,
    CURVECAPS       = 28,
    LINECAPS        = 30,
    POLYGONALCAPS   = 32,
    TEXTCAPS        = 34,
    CLIPCAPS        = 36,
    RASTERCAPS      = 38,
    ASPECTX         = 40,
    ASPECTY         = 42,
    ASPECTXY        = 44,
    LOGPIXELSX      = 88,
    LOGPIXELSY      = 90,
    SIZEPALETTE     = 104,
    NUMRESERVED     = 106,
    COLORRES        = 108,
    PHYSICALWIDTH   = 110,
    PHYSICALHEIGHT  = 111,
    PHYSICALOFFSETX = 112,
    PHYSICALOFFSETY = 113,
    SCALINGFACTORX  = 114,
    SCALINGFACTORY  = 115,
    VREFRESH        = 116,
    DESKTOPVERTRES  = 117,
    DESKTOPHORZRES  = 118,
    BLTALIGNMENT    = 119
}
static if (_WIN32_WINNT >= 0x500) {
enum : int {
    SHADEBLENDCAPS  = 120,
    COLORMGMTCAPS   = 121,
}
}

// Return values for GetDeviceCaps(dc, TECHNOLOGY)
enum : int {
    DT_PLOTTER = 0,
    DT_RASDISPLAY,
    DT_RASPRINTER,
    DT_RASCAMERA,
    DT_CHARSTREAM,
    DT_METAFILE,
    DT_DISPFILE // = 6
}

// Return values for GetDeviceCaps(dc, RASTERCAPS)
enum int
    RC_NONE         = 0,
    RC_BITBLT       = 1,
    RC_BANDING      = 2,
    RC_SCALING      = 4,
    RC_BITMAP64     = 8,
    RC_GDI20_OUTPUT = 16,
    RC_GDI20_STATE  = 32,
    RC_SAVEBITMAP   = 64,
    RC_DI_BITMAP    = 128,
    RC_PALETTE      = 256,
    RC_DIBTODEV     = 512,
    RC_BIGFONT      = 1024,
    RC_STRETCHBLT   = 2048,
    RC_FLOODFILL    = 4096,
    RC_STRETCHDIB   = 8192,
    RC_OP_DX_OUTPUT = 0x4000,
    RC_DEVBITS      = 0x8000;

static if (_WIN32_WINNT >= 0x500) {
    /* Shading and blending caps */
enum SB_NONE = 0x00000000;
enum SB_CONST_ALPHA = 0x00000001;
enum SB_PIXEL_ALPHA = 0x00000002;
enum SB_PREMULT_ALPHA = 0x00000004;
enum SB_GRAD_RECT = 0x00000010;
enum SB_GRAD_TRI = 0x00000020;
    /* Color Management caps */
enum CM_NONE = 0x00000000;
enum CM_DEVICE_ICM = 0x00000001;
enum CM_GAMMA_RAMP = 0x00000002;
enum CM_CMYK_COLOR = 0x00000004;
}

// Return values for GetDeviceCaps(dc, CURVECAPS)
enum int
    CC_NONE       = 0,
    CC_CIRCLES    = 1,
    CC_PIE        = 2,
    CC_CHORD      = 4,
    CC_ELLIPSES   = 8,
    CC_WIDE       = 16,
    CC_STYLED     = 32,
    CC_WIDESTYLED = 64,
    CC_INTERIORS  = 128,
    CC_ROUNDRECT  = 256;

// Return values for GetDeviceCaps(dc, LINECAPS)

enum int
    LC_NONE       = 0,
    LC_POLYLINE   = 2,
    LC_MARKER     = 4,
    LC_POLYMARKER = 8,
    LC_WIDE       = 16,
    LC_STYLED     = 32,
    LC_WIDESTYLED = 64,
    LC_INTERIORS  = 128;

// Return values for GetDeviceCaps(dc, POLYGONALCAPS)

enum int
    PC_NONE        = 0,
    PC_POLYGON     = 1,
    PC_RECTANGLE   = 2,
    PC_WINDPOLYGON = 4,
    PC_TRAPEZOID   = 4,
    PC_SCANLINE    = 8,
    PC_WIDE        = 16,
    PC_STYLED      = 32,
    PC_WIDESTYLED  = 64,
    PC_INTERIORS   = 128,
    PC_POLYPOLYGON = 256,
    PC_PATHS       = 512;

/* Clipping Capabilities */
enum int CP_NONE = 0,
    CP_RECTANGLE = 1,
    CP_REGION = 2;

// Return values for GetDeviceCaps(dc, TEXTCAPS)

enum int
    TC_OP_CHARACTER = 1,
    TC_OP_STROKE    = 2,
    TC_CP_STROKE    = 4,
    TC_CR_90        = 8,
    TC_CR_ANY       = 16,
    TC_SF_X_YINDEP  = 32,
    TC_SA_DOUBLE    = 64,
    TC_SA_INTEGER   = 128,
    TC_SA_CONTIN    = 256,
    TC_EA_DOUBLE    = 512,
    TC_IA_ABLE      = 1024,
    TC_UA_ABLE      = 2048,
    TC_SO_ABLE      = 4096,
    TC_RA_ABLE      = 8192,
    TC_VA_ABLE      = 16384,
    TC_RESERVED     = 32768,
    TC_SCROLLBLT    = 65536;

// End GetDeviceCaps
//---------------------
// GetCharacterPlacement(), and GetFontLanguageInfo()
enum DWORD
    GCP_DBCS            = 1,
    GCP_REORDER         = 2,
    GCP_USEKERNING      = 8,
    GCP_GLYPHSHAPE      = 16,
    GCP_LIGATE          = 32,
    GCP_DIACRITIC       = 256,
    GCP_KASHIDA         = 1024,
    GCP_ERROR           = 0x8000,
    GCP_JUSTIFY         = 0x10000,
    GCP_CLASSIN         = 0x80000,
    GCP_MAXEXTENT       = 0x100000,
    GCP_JUSTIFYIN       = 0x200000,
    GCP_DISPLAYZWG      = 0x400000,
    GCP_SYMSWAPOFF      = 0x800000,
    GCP_NUMERICOVERRIDE = 0x1000000,
    GCP_NEUTRALOVERRIDE = 0x2000000,
    GCP_NUMERICSLATIN   = 0x4000000,
    GCP_NUMERICSLOCAL   = 0x8000000,
    // Only for GetFontLanguageInfo()
    FLI_GLYPHS          = 0x40000,
    FLI_MASK            = 0x103b;

// GetGlyphOutline()
enum : UINT {
    GGO_METRICS      = 0,
    GGO_BITMAP       = 1,
    GGO_NATIVE       = 2,
    GGO_BEZIER       = 3,
    GGO_GRAY2_BITMAP = 4,
    GGO_GRAY4_BITMAP = 5,
    GGO_GRAY8_BITMAP = 6,
    GGO_GLYPH_INDEX  = 128,
    GGO_UNHINTED     = 256
}

enum : int {
    GM_COMPATIBLE = 1,
    GM_ADVANCED
}
enum GM_LAST = GM_ADVANCED;

enum : int {
    MM_TEXT = 1,
    MM_LOMETRIC,
    MM_HIMETRIC,
    MM_LOENGLISH,
    MM_HIENGLISH,
    MM_TWIPS,
    MM_ISOTROPIC,
    MM_ANISOTROPIC,
}

enum int
    MM_MIN = MM_TEXT,
    MM_MAX = MM_ANISOTROPIC,
    MM_MAX_FIXEDSCALE = MM_TWIPS;

enum ABSOLUTE = 1;
enum RELATIVE = 2;

enum : BYTE {
    PC_RESERVED   = 1,
    PC_EXPLICIT   = 2,
    PC_NOCOLLAPSE = 4
}

/* FIXME: move to core.sys.windows.commctrl ? */
// ImageList
enum COLORREF
    CLR_NONE    = 0xffffffff,
    CLR_INVALID = CLR_NONE,
    CLR_DEFAULT = 0xff000000;

// RASTERIZER_STATUS.wFlags
enum short
    TT_AVAILABLE = 1,
    TT_ENABLED   = 2;

// GetStockObject()
enum : int {
    WHITE_BRUSH = 0,
    LTGRAY_BRUSH,
    GRAY_BRUSH,
    DKGRAY_BRUSH,
    BLACK_BRUSH,
    HOLLOW_BRUSH, // = 5
    NULL_BRUSH = HOLLOW_BRUSH,
    WHITE_PEN = 6,
    BLACK_PEN,
    NULL_PEN, // = 8
    OEM_FIXED_FONT = 10,
    ANSI_FIXED_FONT,
    ANSI_VAR_FONT,
    SYSTEM_FONT,
    DEVICE_DEFAULT_FONT,
    DEFAULT_PALETTE,
    SYSTEM_FIXED_FONT,
    DEFAULT_GUI_FONT = SYSTEM_FIXED_FONT + 1,
}
static if (_WIN32_WINNT >= 0x500) {
    enum : int {
        DC_BRUSH = DEFAULT_GUI_FONT + 1,
        DC_PEN,
    }
}

static if (_WIN32_WINNT >= 0x500) {
enum STOCK_LAST = DC_PEN;
} else {
enum STOCK_LAST = DEFAULT_GUI_FONT;
}

// Get/SetSystemPaletteUse()
enum : UINT {
    SYSPAL_ERROR    = 0,
    SYSPAL_STATIC   = 1,
    SYSPAL_NOSTATIC = 2,
    SYSPAL_NOSTATIC256 = 3,
}

// SetTextAlign()
enum UINT
    TA_TOP        = 0,
    TA_CENTER     = 6,
    TA_BOTTOM     = 8,
    TA_BASELINE   = 24,
    TA_LEFT       = 0,
    TA_RIGHT      = 2,
    TA_RTLREADING = 256,
    TA_NOUPDATECP = 0,
    TA_UPDATECP   = 1,
    TA_MASK       = TA_BASELINE+TA_CENTER+TA_UPDATECP+TA_RTLREADING,
    VTA_BASELINE  = TA_BASELINE,
    VTA_CENTER    = TA_CENTER,
    VTA_LEFT      = TA_BOTTOM,
    VTA_RIGHT     = TA_TOP,
    VTA_BOTTOM    = TA_RIGHT,
    VTA_TOP       = TA_LEFT;

// EMRMODIFYWORLDTRANSFORM.iMode
enum : DWORD {
    MWT_IDENTITY = 1,
    MWT_LEFTMULTIPLY,
    MWT_RIGHTMULTIPLY
}

enum DWORD
    MWT_MIN = MWT_IDENTITY,
    MWT_MAX = MWT_RIGHTMULTIPLY;

enum {
    TRANSPARENT = 1,
    OPAQUE      = 2
}

// Get/SetStretchMode()
enum : int {
    BLACKONWHITE = 1,
    WHITEONBLACK = 2,
    COLORONCOLOR = 3,
    HALFTONE     = 4,

    STRETCH_ANDSCANS    = 1,
    STRETCH_ORSCANS     = 2,
    STRETCH_DELETESCANS = 3,
    STRETCH_HALFTONE    = 4,

    MAXSTRETCHBLTMODE   = 4
}

// TranslateCharsetInfo()
enum : DWORD {
    TCI_SRCCHARSET  = 1,
    TCI_SRCCODEPAGE = 2,
    TCI_SRCFONTSIG  = 3,
    TCI_SRCLOCALE   = 0x1000,
}

// SetICMMode()
enum : int {
    ICM_OFF   = 1,
    ICM_ON    = 2,
    ICM_QUERY = 3,
    ICM_DONE_OUTSIDEDC = 4,
}

// ----
// Escape() Spooler Error Codes
enum : int {
    SP_NOTREPORTED = 0x4000,
    SP_ERROR       = -1,
    SP_APPABORT    = -2,
    SP_USERABORT   = -3,
    SP_OUTOFDISK   = -4,
    SP_OUTOFMEMORY = -5
}

// Escape(), ExtEscape()
// Most of the following are deprecated (Win16 only)
enum : int {
    NEWFRAME      = 1,
    ABORTDOC      = 2,
    NEXTBAND      = 3,
    SETCOLORTABLE = 4,
    GETCOLORTABLE = 5,
    FLUSHOUTPUT   = 6,
    DRAFTMODE     = 7,
    QUERYESCSUPPORT = 8,
    SETABORTPROC  = 9,
    STARTDOC      = 10,
    ENDDOC        = 11,
    GETPHYSPAGESIZE   = 12,
    GETPRINTINGOFFSET = 13,
    GETSCALINGFACTOR  = 14,
    MFCOMMENT         = 15,
    GETPENWIDTH       = 16,
    SETCOPYCOUNT      = 17,
    SELECTPAPERSOURCE = 18,
    DEVICEDATA        = 19,
    PASSTHROUGH       = 19,
    GETTECHNOLOGY     = 20,
    SETLINECAP = 21,
    SETLINEJOIN = 22,
    SETMITERLIMIT = 23,
    BANDINFO = 24,
    DRAWPATTERNRECT = 25,
    GETVECTORPENSIZE = 26,
    GETVECTORBRUSHSIZE = 27,
    ENABLEDUPLEX = 28,
    GETSETPAPERBINS = 29,
    GETSETPRINTORIENT = 30,
    ENUMPAPERBINS = 31,
    SETDIBSCALING = 32,
    EPSPRINTING = 33,
    ENUMPAPERMETRICS = 34,
    GETSETPAPERMETRICS = 35,
    POSTSCRIPT_DATA = 37,
    POSTSCRIPT_IGNORE = 38,
    MOUSETRAILS = 39,
    GETDEVICEUNITS = 42,
    GETEXTENDEDTEXTMETRICS = 256,
    GETEXTENTTABLE = 257,
    GETPAIRKERNTABLE = 258,
    GETTRACKKERNTABLE = 259,
    EXTTEXTOUT = 512,
    GETFACENAME = 513,
    DOWNLOADFACE = 514,
    ENABLERELATIVEWIDTHS = 768,
    ENABLEPAIRKERNING = 769,
    SETKERNTRACK = 770,
    SETALLJUSTVALUES = 771,
    SETCHARSET = 772,
    STRETCHBLT = 2048,
    METAFILE_DRIVER = 2049,
    GETSETSCREENPARAMS = 3072,
    QUERYDIBSUPPORT = 3073,
    BEGIN_PATH = 4096,
    CLIP_TO_PATH = 4097,
    END_PATH = 4098,
    EXT_DEVICE_CAPS = 4099,
    RESTORE_CTM = 4100,
    SAVE_CTM = 4101,
    SET_ARC_DIRECTION = 4102,
    SET_BACKGROUND_COLOR = 4103,
    SET_POLY_MODE = 4104,
    SET_SCREEN_ANGLE = 4105,
    SET_SPREAD = 4106,
    TRANSFORM_CTM = 4107,
    SET_CLIP_BOX = 4108,
    SET_BOUNDS = 4109,
    SET_MIRROR_MODE = 4110,
    OPENCHANNEL = 4110,
    DOWNLOADHEADER = 4111,
    CLOSECHANNEL = 4112,
    POSTSCRIPT_PASSTHROUGH  = 4115,
    ENCAPSULATED_POSTSCRIPT = 4116,
    POSTSCRIPT_IDENTIFY = 4117,
    POSTSCRIPT_INJECTION = 4118,
    CHECKJPEGFORMAT = 4119,
    CHECKPNGFORMAT = 4120,
    GET_PS_FEATURESETTING = 4121,
    SPCLPASSTHROUGH2 = 4568,
}

enum : int {
    PSIDENT_GDICENTRIC = 0,
    PSIDENT_PSCENTRIC = 1,
}

/*
 * Header structure for the input buffer to POSTSCRIPT_INJECTION escape
 */
struct PSINJECTDATA {
    DWORD DataBytes;
    WORD  InjectionPoint;
    WORD  PageNumber;
}
alias PPSINJECTDATA = PSINJECTDATA*;

/* Constants for PSINJECTDATA.InjectionPoint field */
enum {
    PSINJECT_BEGINSTREAM = 1,
    PSINJECT_PSADOBE = 2,
    PSINJECT_PAGESATEND = 3,
    PSINJECT_PAGES = 4,
    PSINJECT_DOCNEEDEDRES = 5,
    PSINJECT_DOCSUPPLIEDRES = 6,
    PSINJECT_PAGEORDER = 7,
    PSINJECT_ORIENTATION = 8,
    PSINJECT_BOUNDINGBOX = 9,
    PSINJECT_DOCUMENTPROCESSCOLORS = 10,
    PSINJECT_COMMENTS = 11,
    PSINJECT_BEGINDEFAULTS = 12,
    PSINJECT_ENDDEFAULTS = 13,
    PSINJECT_BEGINPROLOG = 14,
    PSINJECT_ENDPROLOG = 15,
    PSINJECT_BEGINSETUP = 16,
    PSINJECT_ENDSETUP = 17,
    PSINJECT_TRAILER = 18,
    PSINJECT_EOF = 19,
    PSINJECT_ENDSTREAM = 20,
    PSINJECT_DOCUMENTPROCESSCOLORSATEND = 21,

    PSINJECT_PAGENUMBER = 100,
    PSINJECT_BEGINPAGESETUP = 101,
    PSINJECT_ENDPAGESETUP = 102,
    PSINJECT_PAGETRAILER = 103,
    PSINJECT_PLATECOLOR = 104,
    PSINJECT_SHOWPAGE = 105,
    PSINJECT_PAGEBBOX = 106,
    PSINJECT_ENDPAGECOMMENTS = 107,

    PSINJECT_VMSAVE = 200,
    PSINJECT_VMRESTORE = 201,
}

/* Parameter for GET_PS_FEATURESETTING escape */
enum {
    FEATURESETTING_NUP = 0,
    FEATURESETTING_OUTPUT = 1,
    FEATURESETTING_PSLEVEL = 2,
    FEATURESETTING_CUSTPAPER = 3,
    FEATURESETTING_MIRROR = 4,
    FEATURESETTING_NEGATIVE = 5,
    FEATURESETTING_PROTOCOL = 6,
}

enum {
    FEATURESETTING_PRIVATE_BEGIN = 0x1000,
    FEATURESETTING_PRIVATE_END = 0x1FFF,
}

/* Value returned for FEATURESETTING_PROTOCOL */
enum PSPROTOCOL_ASCII = 0;
enum PSPROTOCOL_BCP = 1;
enum PSPROTOCOL_TBCP = 2;
enum PSPROTOCOL_BINARY = 3;

// ----

enum WPARAM PR_JOBSTATUS = 0;

// ???
enum QDI_SETDIBITS   = 1;
enum QDI_GETDIBITS   = 2;
enum QDI_DIBTOSCREEN = 4;
enum QDI_STRETCHDIB  = 8;

enum ASPECT_FILTERING = 1;

// LOGCOLORSPACE.lcsCSType
enum : LCSCSTYPE {
    LCS_CALIBRATED_RGB = 0,
    LCS_DEVICE_RGB,
    LCS_DEVICE_CMYK
} /* What this for? */

// LOGCOLORSPACE.lcsIntent
enum : LCSGAMUTMATCH {
    LCS_GM_BUSINESS         = 1,
    LCS_GM_GRAPHICS         = 2,
    LCS_GM_IMAGES           = 4,
    LCS_GM_ABS_COLORIMETRIC = 8,
}

enum DWORD
    RASTER_FONTTYPE   = 1,
    DEVICE_FONTTYPE   = 2,
    TRUETYPE_FONTTYPE = 4;

// ---
// DEVMODE struct

// FIXME: Not needed for D (use .length instead)
enum CCHDEVICENAME = 32;
enum CCHFORMNAME   = 32;

// DEVMODE.dmSpecVersion
// current version of specification
enum WORD DM_SPECVERSION = 0x0401;

// DEVMODE.dmOrientation
enum : short {
    DMORIENT_PORTRAIT  = 1,
    DMORIENT_LANDSCAPE = 2
}

// DEVMODE.dmPaperSize
enum : short {
    DMPAPER_LETTER = 1,
    DMPAPER_LETTERSMALL,
    DMPAPER_TABLOID,
    DMPAPER_LEDGER,
    DMPAPER_LEGAL,
    DMPAPER_STATEMENT,
    DMPAPER_EXECUTIVE,
    DMPAPER_A3,
    DMPAPER_A4,
    DMPAPER_A4SMALL,
    DMPAPER_A5,
    DMPAPER_B4,
    DMPAPER_B5,
    DMPAPER_FOLIO,
    DMPAPER_QUARTO,
    DMPAPER_10X14,
    DMPAPER_11X17,
    DMPAPER_NOTE,
    DMPAPER_ENV_9,
    DMPAPER_ENV_10,
    DMPAPER_ENV_11,
    DMPAPER_ENV_12,
    DMPAPER_ENV_14,
    DMPAPER_CSHEET,
    DMPAPER_DSHEET,
    DMPAPER_ESHEET,
    DMPAPER_ENV_DL,
    DMPAPER_ENV_C5,
    DMPAPER_ENV_C3,
    DMPAPER_ENV_C4,
    DMPAPER_ENV_C6,
    DMPAPER_ENV_C65,
    DMPAPER_ENV_B4,
    DMPAPER_ENV_B5,
    DMPAPER_ENV_B6,
    DMPAPER_ENV_ITALY,
    DMPAPER_ENV_MONARCH,
    DMPAPER_ENV_PERSONAL,
    DMPAPER_FANFOLD_US,
    DMPAPER_FANFOLD_STD_GERMAN,
    DMPAPER_FANFOLD_LGL_GERMAN,
    DMPAPER_ISO_B4,
    DMPAPER_JAPANESE_POSTCARD,
    DMPAPER_9X11,
    DMPAPER_10X11,
    DMPAPER_15X11,
    DMPAPER_ENV_INVITE,
    DMPAPER_RESERVED_48,
    DMPAPER_RESERVED_49,
    DMPAPER_LETTER_EXTRA,
    DMPAPER_LEGAL_EXTRA,
    DMPAPER_TABLOID_EXTRA,
    DMPAPER_A4_EXTRA,
    DMPAPER_LETTER_TRANSVERSE,
    DMPAPER_A4_TRANSVERSE,
    DMPAPER_LETTER_EXTRA_TRANSVERSE,
    DMPAPER_A_PLUS,
    DMPAPER_B_PLUS,
    DMPAPER_LETTER_PLUS,
    DMPAPER_A4_PLUS,
    DMPAPER_A5_TRANSVERSE,
    DMPAPER_B5_TRANSVERSE,
    DMPAPER_A3_EXTRA,
    DMPAPER_A5_EXTRA,
    DMPAPER_B5_EXTRA,
    DMPAPER_A2,
    DMPAPER_A3_TRANSVERSE,
    DMPAPER_A3_EXTRA_TRANSVERSE // = 68
}
static if (_WIN32_WINNT >= 0x500) {
    enum : short {
        DMPAPER_DBL_JAPANESE_POSTCARD = 69,
        DMPAPER_A6,
        DMPAPER_JENV_KAKU2,
        DMPAPER_JENV_KAKU3,
        DMPAPER_JENV_CHOU3,
        DMPAPER_JENV_CHOU4,
        DMPAPER_LETTER_ROTATED,
        DMPAPER_A3_ROTATED,
        DMPAPER_A4_ROTATED,
        DMPAPER_A5_ROTATED,
        DMPAPER_B4_JIS_ROTATED,
        DMPAPER_B5_JIS_ROTATED,
        DMPAPER_JAPANESE_POSTCARD_ROTATED,
        DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED,
        DMPAPER_A6_ROTATED,
        DMPAPER_JENV_KAKU2_ROTATED,
        DMPAPER_JENV_KAKU3_ROTATED,
        DMPAPER_JENV_CHOU3_ROTATED,
        DMPAPER_JENV_CHOU4_ROTATED,
        DMPAPER_B6_JIS,
        DMPAPER_B6_JIS_ROTATED,
        DMPAPER_12X11,
        DMPAPER_JENV_YOU4,
        DMPAPER_JENV_YOU4_ROTATED,
        DMPAPER_P16K,
        DMPAPER_P32K,
        DMPAPER_P32KBIG,
        DMPAPER_PENV_1,
        DMPAPER_PENV_2,
        DMPAPER_PENV_3,
        DMPAPER_PENV_4,
        DMPAPER_PENV_5,
        DMPAPER_PENV_6,
        DMPAPER_PENV_7,
        DMPAPER_PENV_8,
        DMPAPER_PENV_9,
        DMPAPER_PENV_10,
        DMPAPER_P16K_ROTATED,
        DMPAPER_P32K_ROTATED,
        DMPAPER_P32KBIG_ROTATED,
        DMPAPER_PENV_1_ROTATED,
        DMPAPER_PENV_2_ROTATED,
        DMPAPER_PENV_3_ROTATED,
        DMPAPER_PENV_4_ROTATED,
        DMPAPER_PENV_5_ROTATED,
        DMPAPER_PENV_6_ROTATED,
        DMPAPER_PENV_7_ROTATED,
        DMPAPER_PENV_8_ROTATED,
        DMPAPER_PENV_9_ROTATED,
        DMPAPER_PENV_10_ROTATED // 118
    }
}

enum short DMPAPER_FIRST = DMPAPER_LETTER;

static if (_WIN32_WINNT >= 0x500) {
enum short DMPAPER_LAST = DMPAPER_PENV_10_ROTATED;
} else {
enum short DMPAPER_LAST = DMPAPER_A3_EXTRA_TRANSVERSE;
}

enum short DMPAPER_USER = 256;


// DEVMODE.dmDefaultSource
enum : short {
    DMBIN_ONLYONE = 1,
    DMBIN_UPPER   = 1,
    DMBIN_LOWER,
    DMBIN_MIDDLE,
    DMBIN_MANUAL,
    DMBIN_ENVELOPE,
    DMBIN_ENVMANUAL,
    DMBIN_AUTO,
    DMBIN_TRACTOR,
    DMBIN_SMALLFMT,
    DMBIN_LARGEFMT,
    DMBIN_LARGECAPACITY, // = 11
    DMBIN_CASSETTE   = 14,
    DMBIN_FORMSOURCE,
}
enum : short {
    DMBIN_FIRST = DMBIN_UPPER,
    DMBIN_LAST = DMBIN_FORMSOURCE,
    DMBIN_USER = 256,
}

// DEVMODE.dmPrintQuality
enum : short {
    DMRES_DRAFT  = -1,
    DMRES_LOW    = -2,
    DMRES_MEDIUM = -3,
    DMRES_HIGH   = -4
}

// DEVMODE.dmColor
enum : short {
    DMCOLOR_MONOCHROME = 1,
    DMCOLOR_COLOR      = 2
}

// DEVMODE.dmDuplex
enum : short {
    DMDUP_SIMPLEX    = 1,
    DMDUP_VERTICAL   = 2,
    DMDUP_HORIZONTAL = 3
}

// DEVMODE.dmTTOption
enum : short {
    DMTT_BITMAP = 1,
    DMTT_DOWNLOAD,
    DMTT_SUBDEV,
    DMTT_DOWNLOAD_OUTLINE
}

// DEVMODE.dmCollate
enum : short {
    DMCOLLATE_FALSE = 0,
    DMCOLLATE_TRUE
}

static if (_WIN32_WINNT >= 0x501) {
    /* DEVMODE dmDisplayOrientation specifiations */
    enum : short {
        DMDO_DEFAULT = 0,
        DMDO_90 = 1,
        DMDO_180 = 2,
        DMDO_270 = 3,
    }

    /* DEVMODE dmDisplayFixedOutput specifiations */
    enum : short {
        DMDFO_DEFAULT = 0,
        DMDFO_STRETCH = 1,
        DMDFO_CENTER = 2,
    }
}


/* FIXME: this flags are deprecated ? */
// DEVMODE.dmDisplayFlags
enum DWORD
    DM_GRAYSCALE  = 1,
    DM_INTERLACED = 2;

enum DWORD
    DMDISPLAYFLAGS_TEXTMODE = 0x00000004;

/* dmNup , multiple logical page per physical page options */
enum DWORD
    DMNUP_SYSTEM = 1,
    DMNUP_ONEUP = 2;

// DEVMODE.dmFields
enum DWORD
    DM_ORIENTATION        = 0x00000001,
    DM_PAPERSIZE          = 0x00000002,
    DM_PAPERLENGTH        = 0x00000004,
    DM_PAPERWIDTH         = 0x00000008,
    DM_SCALE              = 0x00000010;
static if (_WIN32_WINNT >= 0x500) {
enum DWORD
        DM_POSITION       = 0x00000020,
        DM_NUP            = 0x00000040;
}
static if (_WIN32_WINNT >= 0x501) {
enum DWORD
        DM_DISPLAYORIENTATION = 0x00000080;
}
enum DWORD
    DM_COPIES             = 0x00000100,
    DM_DEFAULTSOURCE      = 0x00000200,
    DM_PRINTQUALITY       = 0x00000400,
    DM_COLOR              = 0x00000800,
    DM_DUPLEX             = 0x00001000,
    DM_YRESOLUTION        = 0x00002000,
    DM_TTOPTION           = 0x00004000,
    DM_COLLATE            = 0x00008000,
    DM_FORMNAME           = 0x00010000,
    DM_LOGPIXELS          = 0x00020000,
    DM_BITSPERPEL         = 0x00040000,
    DM_PELSWIDTH          = 0x00080000,
    DM_PELSHEIGHT         = 0x00100000,
    DM_DISPLAYFLAGS       = 0x00200000,
    DM_DISPLAYFREQUENCY   = 0x00400000,
    DM_ICMMETHOD          = 0x00800000,
    DM_ICMINTENT          = 0x01000000,
    DM_MEDIATYPE          = 0x02000000,
    DM_DITHERTYPE         = 0x04000000,
    DM_PANNINGWIDTH       = 0x08000000,
    DM_PANNINGHEIGHT      = 0x10000000;
static if (_WIN32_WINNT >= 0x501) {
enum DWORD
        DM_DISPLAYFIXEDOUTPUT = 0x20000000;
}

// DEVMODE.dmICMMethod
enum : DWORD {
    DMICMMETHOD_NONE   = 1,
    DMICMMETHOD_SYSTEM = 2,
    DMICMMETHOD_DRIVER = 3,
    DMICMMETHOD_DEVICE = 4,
    DMICMMETHOD_USER   = 256
}

// DEVMODE.dmICMIntent
enum : DWORD {
    DMICM_SATURATE    = 1,
    DMICM_CONTRAST    = 2,
    DMICM_COLORIMETRIC = 3,
    DMICM_ABS_COLORIMETRIC = 4,
    DMICM_USER        = 256
}

// DEVMODE.dmMediaType
enum : DWORD {
    DMMEDIA_STANDARD     = 1,
    DMMEDIA_TRANSPARENCY = 2,
    DMMEDIA_GLOSSY       = 3,
    DMMEDIA_USER         = 256
}

// DEVMODE.dmDitherType
enum : DWORD {
    DMDITHER_NONE = 1,
    DMDITHER_COARSE,
    DMDITHER_FINE,
    DMDITHER_LINEART,
    DMDITHER_ERRORDIFFUSION,
    DMDITHER_RESERVED6,
    DMDITHER_RESERVED7,
    DMDITHER_RESERVED8,
    DMDITHER_RESERVED9,
    DMDITHER_GRAYSCALE,
    DMDITHER_USER = 256
}

// ----
// DocumentProperties()
enum DWORD
    DM_UPDATE      = 1,
    DM_COPY        = 2,
    DM_PROMPT      = 4,
    DM_MODIFY      = 8,
    DM_IN_BUFFER   = DM_MODIFY,
    DM_IN_PROMPT   = DM_PROMPT,
    DM_OUT_BUFFER  = DM_COPY,
    DM_OUT_DEFAULT = DM_UPDATE;
// ---

enum GDI_ERROR = 0xFFFFFFFF;
enum HGDI_ERROR= cast(HANDLE)GDI_ERROR;

// TEXTMETRIC.tmPitchAndFamily
enum BYTE
    TMPF_FIXED_PITCH = 1,
    TMPF_VECTOR      = 2,
    TMPF_TRUETYPE    = 4,
    TMPF_DEVICE      = 8;

// NEWTEXTMETRIC.ntmFlags
enum DWORD
    NTM_ITALIC         = 0x00000001,
    NTM_BOLD           = 0x00000020,
    NTM_REGULAR        = 0x00000040,
    NTM_NONNEGATIVE_AC = 0x00010000,
    NTM_PS_OPENTYPE    = 0x00020000,
    NTM_TT_OPENTYPE    = 0x00040000,
    NTM_MULTIPLEMASTER = 0x00080000,
    NTM_TYPE1          = 0x00100000,
    NTM_DSIG           = 0x00200000;

// ---
enum DWORD TT_POLYGON_TYPE = 24;

// TTPOLYCURVE
enum : WORD {
    TT_PRIM_LINE    = 1,
    TT_PRIM_QSPLINE = 2,
    TT_PRIM_CSPLINE = 3,
}
// ---
enum FONTMAPPER_MAX = 10;
enum ENHMETA_STOCK_OBJECT = 0x80000000;
enum WGL_FONT_LINES = 0;
enum WGL_FONT_POLYGONS = 1;

// ---
// LAYERPLANEDESCRIPTOR.dwFlags
enum DWORD
    LPD_DOUBLEBUFFER   = 1,
    LPD_STEREO         = 2,
    LPD_SUPPORT_GDI    = 16,
    LPD_SUPPORT_OPENGL = 32,
    LPD_SHARE_DEPTH    = 64,
    LPD_SHARE_STENCIL  = 128,
    LPD_SHARE_ACCUM    = 256,
    LPD_SWAP_EXCHANGE  = 512,
    LPD_SWAP_COPY      = 1024,
    LPD_TRANSPARENT    = 4096;

// LAYERPLANEDESCRIPTOR.iPixelType
enum : BYTE {
    LPD_TYPE_RGBA       = 0,
    LPD_TYPE_COLORINDEX = 1
}

// ---

// wglSwapLayerBuffers()
enum UINT
    WGL_SWAP_MAIN_PLANE = 1,
    WGL_SWAP_OVERLAY1   = 2,
    WGL_SWAP_OVERLAY2   = 4,
    WGL_SWAP_OVERLAY3   = 8,
    WGL_SWAP_OVERLAY4   = 16,
    WGL_SWAP_OVERLAY5   = 32,
    WGL_SWAP_OVERLAY6   = 64,
    WGL_SWAP_OVERLAY7   = 128,
    WGL_SWAP_OVERLAY8   = 256,
    WGL_SWAP_OVERLAY9   = 512,
    WGL_SWAP_OVERLAY10  = 1024,
    WGL_SWAP_OVERLAY11  = 2048,
    WGL_SWAP_OVERLAY12  = 4096,
    WGL_SWAP_OVERLAY13  = 8192,
    WGL_SWAP_OVERLAY14  = 16384,
    WGL_SWAP_OVERLAY15  = 32768,
    WGL_SWAP_UNDERLAY1  = 65536,
    WGL_SWAP_UNDERLAY2  = 0x20000,
    WGL_SWAP_UNDERLAY3  = 0x40000,
    WGL_SWAP_UNDERLAY4  = 0x80000,
    WGL_SWAP_UNDERLAY5  = 0x100000,
    WGL_SWAP_UNDERLAY6  = 0x200000,
    WGL_SWAP_UNDERLAY7  = 0x400000,
    WGL_SWAP_UNDERLAY8  = 0x800000,
    WGL_SWAP_UNDERLAY9  = 0x1000000,
    WGL_SWAP_UNDERLAY10 = 0x2000000,
    WGL_SWAP_UNDERLAY11 = 0x4000000,
    WGL_SWAP_UNDERLAY12 = 0x8000000,
    WGL_SWAP_UNDERLAY13 = 0x10000000,
    WGL_SWAP_UNDERLAY14 = 0x20000000,
    WGL_SWAP_UNDERLAY15 = 0x40000000;

enum AC_SRC_OVER  = 0x00;
enum AC_SRC_ALPHA = 0x01;

// ???
enum AC_SRC_NO_PREMULT_ALPHA = 0x01;
enum AC_SRC_NO_ALPHA         = 0x02;
enum AC_DST_NO_PREMULT_ALPHA = 0x10;
enum AC_DST_NO_ALPHA         = 0x20;

enum LAYOUT_RTL = 1;
enum LAYOUT_BTT = 2;
enum LAYOUT_VBH = 4;
enum LAYOUT_BITMAPORIENTATIONPRESERVED = 8;

enum CS_ENABLE = 0x00000001;
enum CS_DISABLE = 0x00000002;
enum CS_DELETE_TRANSFORM = 0x00000003;

static if (_WIN32_WINNT > 0x500) {
enum GRADIENT_FILL_RECT_H=0x00;
enum GRADIENT_FILL_RECT_V=0x01;
enum GRADIENT_FILL_TRIANGLE=0x02;
enum GRADIENT_FILL_OP_FLAG=0xff;
enum COLORMATCHTOTARGET_EMBEDED=0x00000001;
enum CREATECOLORSPACE_EMBEDED=0x00000001;
enum SETICMPROFILE_EMBEDED=0x00000001;
}

// DISPLAY_DEVICE.StateFlags
enum DWORD
    DISPLAY_DEVICE_ATTACHED_TO_DESKTOP = 0x00000001,
    DISPLAY_DEVICE_MULTI_DRIVER        = 0x00000002,
    DISPLAY_DEVICE_PRIMARY_DEVICE      = 0x00000004,
    DISPLAY_DEVICE_MIRRORING_DRIVER    = 0x00000008,
    DISPLAY_DEVICE_VGA_COMPATIBLE      = 0x00000010,
    DISPLAY_DEVICE_REMOVABLE           = 0x00000020,
    DISPLAY_DEVICE_DISCONNECT          = 0x02000000,
    DISPLAY_DEVICE_REMOTE              = 0x04000000,
    DISPLAY_DEVICE_MODESPRUNED         = 0x08000000;

/* Child device state */
enum DWORD
    DISPLAY_DEVICE_ACTIVE = 0x00000001,
    DISPLAY_DEVICE_ATTACHED = 0x00000002;

static if (_WIN32_WINNT >= 0x500) {
enum GGI_MARK_NONEXISTING_GLYPHS = 1;
}

// ----------
//   STRUCTS
// ----------

struct ABC {
    int  abcA;
    UINT abcB;
    int  abcC;
}
alias PABC = ABC*, NPABC = ABC*, LPABC = ABC*;

struct ABCFLOAT {
    FLOAT abcfA;
    FLOAT abcfB;
    FLOAT abcfC;
}
alias PABCFLOAT = ABCFLOAT*, NPABCFLOAT = ABCFLOAT*, LPABCFLOAT = ABCFLOAT*;

struct BITMAP {
    LONG   bmType;
    LONG   bmWidth;
    LONG   bmHeight;
    LONG   bmWidthBytes;
    WORD   bmPlanes;
    WORD   bmBitsPixel;
    LPVOID bmBits;
}
alias PBITMAP = BITMAP*, NPBITMAP = BITMAP*, LPBITMAP = BITMAP*;

struct BITMAPCOREHEADER {
    DWORD bcSize;
    WORD  bcWidth;
    WORD  bcHeight;
    WORD  bcPlanes;
    WORD  bcBitCount;
}
alias PBITMAPCOREHEADER = BITMAPCOREHEADER*, LPBITMAPCOREHEADER = BITMAPCOREHEADER*;

align(1):
struct RGBTRIPLE {
    BYTE rgbtBlue;
    BYTE rgbtGreen;
    BYTE rgbtRed;
}
alias LPRGBTRIPLE = RGBTRIPLE*;

align(2):
struct BITMAPFILEHEADER {
align(2):
    WORD  bfType;
    DWORD bfSize;
    WORD  bfReserved1;
    WORD  bfReserved2;
    DWORD bfOffBits;
}
alias LPBITMAPFILEHEADER = BITMAPFILEHEADER*, PBITMAPFILEHEADER = BITMAPFILEHEADER*;

align:

struct BITMAPCOREINFO {
    BITMAPCOREHEADER bmciHeader;
    RGBTRIPLE[1]     bmciColors;
}
alias LPBITMAPCOREINFO = BITMAPCOREINFO*, PBITMAPCOREINFO = BITMAPCOREINFO*;

struct BITMAPINFOHEADER {
    DWORD biSize;
    LONG  biWidth;
    LONG  biHeight;
    WORD  biPlanes;
    WORD  biBitCount;
    DWORD biCompression;
    DWORD biSizeImage;
    LONG  biXPelsPerMeter;
    LONG  biYPelsPerMeter;
    DWORD biClrUsed;
    DWORD biClrImportant;
}

alias LPBITMAPINFOHEADER = BITMAPINFOHEADER*, PBITMAPINFOHEADER = BITMAPINFOHEADER*;

struct RGBQUAD {
    BYTE rgbBlue;
    BYTE rgbGreen;
    BYTE rgbRed;
    BYTE rgbReserved;
}
alias LPRGBQUAD = RGBQUAD*;

struct BITMAPINFO {
    BITMAPINFOHEADER bmiHeader;
    RGBQUAD[1]       bmiColors;
}
alias PBITMAPINFO = BITMAPINFO*, LPBITMAPINFO = BITMAPINFO*;

alias FXPT16DOT16 = int;
alias LPFXPT16DOT16 = int*;
alias FXPT2DOT30 = int;
alias LPFXPT2DOT30 = int*;

struct CIEXYZ {
    FXPT2DOT30 ciexyzX;
    FXPT2DOT30 ciexyzY;
    FXPT2DOT30 ciexyzZ;
}
alias LPCIEXYZ = CIEXYZ*;

struct CIEXYZTRIPLE {
    CIEXYZ ciexyzRed;
    CIEXYZ ciexyzGreen;
    CIEXYZ ciexyzBlue;
}
alias LPCIEXYZTRIPLE = CIEXYZTRIPLE*;

struct BITMAPV4HEADER {
    DWORD        bV4Size;
    LONG         bV4Width;
    LONG         bV4Height;
    WORD         bV4Planes;
    WORD         bV4BitCount;
    DWORD        bV4V4Compression;
    DWORD        bV4SizeImage;
    LONG         bV4XPelsPerMeter;
    LONG         bV4YPelsPerMeter;
    DWORD        bV4ClrUsed;
    DWORD        bV4ClrImportant;
    DWORD        bV4RedMask;
    DWORD        bV4GreenMask;
    DWORD        bV4BlueMask;
    DWORD        bV4AlphaMask;
    DWORD        bV4CSType;
    CIEXYZTRIPLE bV4Endpoints;
    DWORD        bV4GammaRed;
    DWORD        bV4GammaGreen;
    DWORD        bV4GammaBlue;
}
alias LPBITMAPV4HEADER = BITMAPV4HEADER*, PBITMAPV4HEADER = BITMAPV4HEADER*;

struct BITMAPV5HEADER {
    DWORD bV5Size;
    LONG bV5Width;
    LONG bV5Height;
    WORD bV5Planes;
    WORD bV5BitCount;
    DWORD bV5Compression;
    DWORD bV5SizeImage;
    LONG bV5XPelsPerMeter;
    LONG bV5YPelsPerMeter;
    DWORD bV5ClrUsed;
    DWORD bV5ClrImportant;
    DWORD bV5RedMask;
    DWORD bV5GreenMask;
    DWORD bV5BlueMask;
    DWORD bV5AlphaMask;
    DWORD bV5CSType;
    CIEXYZTRIPLE bV5Endpoints;
    DWORD bV5GammaRed;
    DWORD bV5GammaGreen;
    DWORD bV5GammaBlue;
    DWORD bV5Intent;
    DWORD bV5ProfileData;
    DWORD bV5ProfileSize;
    DWORD bV5Reserved;
}
alias LPBITMAPV5HEADER = BITMAPV5HEADER*, PBITMAPV5HEADER = BITMAPV5HEADER*;

struct FONTSIGNATURE {
    DWORD[4] fsUsb;
    DWORD[2] fsCsb;
}
alias PFONTSIGNATURE = FONTSIGNATURE*, LPFONTSIGNATURE = FONTSIGNATURE*;

struct CHARSETINFO {
    UINT ciCharset;
    UINT ciACP;
    FONTSIGNATURE fs;
}
alias PCHARSETINFO = CHARSETINFO*, NPCHARSETINFO = CHARSETINFO*, LPCHARSETINFO = CHARSETINFO*;

struct COLORADJUSTMENT {
    WORD  caSize;
    WORD  caFlags;
    WORD  caIlluminantIndex;
    WORD  caRedGamma;
    WORD  caGreenGamma;
    WORD  caBlueGamma;
    WORD  caReferenceBlack;
    WORD  caReferenceWhite;
    SHORT caContrast;
    SHORT caBrightness;
    SHORT caColorfulness;
    SHORT caRedGreenTint;
}
alias PCOLORADJUSTMENT = COLORADJUSTMENT*, LPCOLORADJUSTMENT = COLORADJUSTMENT*;

struct DEVMODEA {
    BYTE[CCHDEVICENAME] dmDeviceName;
    WORD   dmSpecVersion;
    WORD   dmDriverVersion;
    WORD   dmSize;
    WORD   dmDriverExtra;
    DWORD  dmFields;
    union {
        struct {
            short dmOrientation;
            short dmPaperSize;
            short dmPaperLength;
            short dmPaperWidth;
            short dmScale;
            short dmCopies;
            short dmDefaultSource;
            short dmPrintQuality;
        }
        struct {
            POINTL dmPosition;
            DWORD  dmDisplayOrientation;
            DWORD  dmDisplayFixedOutput;
        }
    }
    short  dmColor;
    short  dmDuplex;
    short  dmYResolution;
    short  dmTTOption;
    short  dmCollate;
    BYTE[CCHFORMNAME]   dmFormName;
    WORD   dmLogPixels;
    DWORD  dmBitsPerPel;
    DWORD  dmPelsWidth;
    DWORD  dmPelsHeight;
    union {
        DWORD  dmDisplayFlags;
        DWORD  dmNup;
    }
    DWORD  dmDisplayFrequency;
    DWORD  dmICMMethod;
    DWORD  dmICMIntent;
    DWORD  dmMediaType;
    DWORD  dmDitherType;
    DWORD  dmReserved1;
    DWORD  dmReserved2;
    DWORD  dmPanningWidth;
    DWORD  dmPanningHeight;
}
alias PDEVMODEA = DEVMODEA*, NPDEVMODEA = DEVMODEA*, LPDEVMODEA = DEVMODEA*;

struct DEVMODEW {
    WCHAR[CCHDEVICENAME]   dmDeviceName = 0;
    WORD   dmSpecVersion;
    WORD   dmDriverVersion;
    WORD   dmSize;
    WORD   dmDriverExtra;
    DWORD  dmFields;
    union {
        struct {
            short dmOrientation;
            short dmPaperSize;
            short dmPaperLength;
            short dmPaperWidth;
            short dmScale;
            short dmCopies;
            short dmDefaultSource;
            short dmPrintQuality;
        }
        struct {
            POINTL dmPosition;
            DWORD  dmDisplayOrientation;
            DWORD  dmDisplayFixedOutput;
        }
    }

    short  dmColor;
    short  dmDuplex;
    short  dmYResolution;
    short  dmTTOption;
    short  dmCollate;
    WCHAR[CCHFORMNAME]  dmFormName = 0;
    WORD   dmLogPixels;
    DWORD  dmBitsPerPel;
    DWORD  dmPelsWidth;
    DWORD  dmPelsHeight;
    union {
        DWORD  dmDisplayFlags;
        DWORD  dmNup;
    }
    DWORD  dmDisplayFrequency;
    DWORD  dmICMMethod;
    DWORD  dmICMIntent;
    DWORD  dmMediaType;
    DWORD  dmDitherType;
    DWORD  dmReserved1;
    DWORD  dmReserved2;
    DWORD  dmPanningWidth;
    DWORD  dmPanningHeight;
}
alias PDEVMODEW = DEVMODEW*, NPDEVMODEW = DEVMODEW*, LPDEVMODEW = DEVMODEW*;

/*
 * Information about output options
 */
struct PSFEATURE_OUTPUT {
    BOOL bPageIndependent;
    BOOL bSetPageDevice;
}
alias PPSFEATURE_OUTPUT = PSFEATURE_OUTPUT*;

/*
 * Information about custom paper size
 */
struct PSFEATURE_CUSTPAPER {
    LONG lOrientation;
    LONG lWidth;
    LONG lHeight;
    LONG lWidthOffset;
    LONG lHeightOffset;
}
alias PPSFEATURE_CUSTPAPER = PSFEATURE_CUSTPAPER*;

struct DIBSECTION {
    BITMAP           dsBm;
    BITMAPINFOHEADER dsBmih;
    DWORD[3]         dsBitfields;
    HANDLE           dshSection;
    DWORD            dsOffset;
}
alias PDIBSECTION = DIBSECTION*;

struct DOCINFOA {
    int    cbSize = DOCINFOA.sizeof;
    LPCSTR lpszDocName;
    LPCSTR lpszOutput;
    LPCSTR lpszDatatype;
    DWORD  fwType;
}
alias LPDOCINFOA = DOCINFOA*;

struct DOCINFOW {
    int     cbSize = DOCINFOW.sizeof;
    LPCWSTR lpszDocName;
    LPCWSTR lpszOutput;
    LPCWSTR lpszDatatype;
    DWORD   fwType;
}
alias LPDOCINFOW = DOCINFOW*;


struct PANOSE {
    BYTE bFamilyType;
    BYTE bSerifStyle;
    BYTE bWeight;
    BYTE bProportion;
    BYTE bContrast;
    BYTE bStrokeVariation;
    BYTE bArmStyle;
    BYTE bLetterform;
    BYTE bMidline;
    BYTE bXHeight;
}
alias LPPANOSE = PANOSE*;

struct LOGFONTA {
    LONG lfHeight;
    LONG lfWidth;
    LONG lfEscapement;
    LONG lfOrientation;
    LONG lfWeight;
    BYTE lfItalic;
    BYTE lfUnderline;
    BYTE lfStrikeOut;
    BYTE lfCharSet;
    BYTE lfOutPrecision;
    BYTE lfClipPrecision;
    BYTE lfQuality;
    BYTE lfPitchAndFamily;
    CHAR[LF_FACESIZE] lfFaceName = 0;
}
alias PLOGFONTA = LOGFONTA*, NPLOGFONTA = LOGFONTA*, LPLOGFONTA = LOGFONTA*;

struct LOGFONTW {
    LONG lfHeight;
    LONG lfWidth;
    LONG lfEscapement;
    LONG lfOrientation;
    LONG lfWeight;
    BYTE lfItalic;
    BYTE lfUnderline;
    BYTE lfStrikeOut;
    BYTE lfCharSet;
    BYTE lfOutPrecision;
    BYTE lfClipPrecision;
    BYTE lfQuality;
    BYTE lfPitchAndFamily;
    WCHAR[LF_FACESIZE] lfFaceName = 0;
}
alias PLOGFONTW = LOGFONTW*, NPLOGFONTW = LOGFONTW*, LPLOGFONTW = LOGFONTW*;

struct EXTLOGFONTA {
    LOGFONTA              elfLogFont;
    BYTE[LF_FULLFACESIZE] elfFullName;
    BYTE[LF_FACESIZE]     elfStyle;
    DWORD                 elfVersion;
    DWORD                 elfStyleSize;
    DWORD                 elfMatch;
    DWORD                 elfReserved;
    BYTE[ELF_VENDOR_SIZE] elfVendorId;
    DWORD                 elfCulture;
    PANOSE                elfPanose;
}
alias PEXTLOGFONTA = EXTLOGFONTA*, NPEXTLOGFONTA = EXTLOGFONTA*, LPEXTLOGFONTA = EXTLOGFONTA*;

struct EXTLOGFONTW {
    LOGFONTW               elfLogFont;
    WCHAR[LF_FULLFACESIZE] elfFullName = 0;
    WCHAR[LF_FACESIZE]     elfStyle = 0;
    DWORD                  elfVersion;
    DWORD                  elfStyleSize;
    DWORD                  elfMatch;
    DWORD                  elfReserved;
    BYTE[ELF_VENDOR_SIZE]  elfVendorId;
    DWORD                  elfCulture;
    PANOSE                 elfPanose;
}
alias PEXTLOGFONTW = EXTLOGFONTW*, NPEXTLOGFONTW = EXTLOGFONTW*, LPEXTLOGFONTW = EXTLOGFONTW*;

struct LOGPEN {
    UINT     lopnStyle;
    POINT    lopnWidth;
    COLORREF lopnColor;
}
alias PLOGPEN = LOGPEN*, NPLOGPEN = LOGPEN*, LPLOGPEN = LOGPEN*;

// ---------------------- EMR ------------

struct EMR {
    DWORD iType;
    DWORD nSize;
}
alias PEMR = EMR*;

struct EMRANGLEARC {
    EMR    emr;
    POINTL ptlCenter;
    DWORD  nRadius;
    FLOAT  eStartAngle;
    FLOAT  eSweepAngle;
}
alias PEMRANGLEARC = EMRANGLEARC*;

struct EMRARC {
    EMR    emr;
    RECTL  rclBox;
    POINTL ptlStart;
    POINTL ptlEnd;
}
alias PEMRARC = EMRARC*;
alias EMRARCTO = EMRARC;
alias PEMRARCTO = EMRARCTO*;
alias EMRCHORD = EMRARC;
alias PEMRCHORD = EMRCHORD*;
alias EMRPIE = EMRARC;
alias PEMRPIE = EMRPIE*;

struct XFORM {
    FLOAT eM11;
    FLOAT eM12;
    FLOAT eM21;
    FLOAT eM22;
    FLOAT eDx;
    FLOAT eDy;
}
alias PXFORM = XFORM*, LPXFORM = XFORM*;

struct EMRBITBLT {
    EMR      emr;
    RECTL    rclBounds;
    LONG     xDest;
    LONG     yDest;
    LONG     cxDest;
    LONG     cyDest;
    DWORD    dwRop;
    LONG     xSrc;
    LONG     ySrc;
    XFORM    xformSrc;
    COLORREF crBkColorSrc;
    DWORD    iUsageSrc;
    DWORD    offBmiSrc;
    DWORD    cbBmiSrc;
    DWORD    offBitsSrc;
    DWORD    cbBitsSrc;
}
alias PEMRBITBLT = EMRBITBLT*;

struct LOGBRUSH {
    UINT     lbStyle;
    COLORREF lbColor;
    ULONG_PTR lbHatch;
}
alias PATTERN = LOGBRUSH;
alias PLOGBRUSH = LOGBRUSH*, NPLOGBRUSH = LOGBRUSH*, LPLOGBRUSH = LOGBRUSH*;
alias PPATTERN = PATTERN*, NPPATTERN = PATTERN*, LPPATTERN = PATTERN*;

struct LOGBRUSH32 {
    UINT lbStyle;
    COLORREF lbColor;
    ULONG lbHatch;
}
alias PLOGBRUSH32 = LOGBRUSH32*, NPLOGBRUSH32 = LOGBRUSH32*, LPLOGBRUSH32 = LOGBRUSH32*;

struct EMRCREATEBRUSHINDIRECT {
    EMR      emr;
    DWORD    ihBrush;
    LOGBRUSH32 lb;
}
alias PEMRCREATEBRUSHINDIRECT = EMRCREATEBRUSHINDIRECT*;

alias LCSCSTYPE = LONG, LCSGAMUTMATCH = LONG;

struct LOGCOLORSPACEA {
    DWORD lcsSignature;
    DWORD lcsVersion;
    DWORD lcsSize;
    LCSCSTYPE lcsCSType;
    LCSGAMUTMATCH lcsIntent;
    CIEXYZTRIPLE lcsEndpoints;
    DWORD lcsGammaRed;
    DWORD lcsGammaGreen;
    DWORD lcsGammaBlue;
    CHAR[MAX_PATH] lcsFilename = 0;
}
alias LPLOGCOLORSPACEA = LOGCOLORSPACEA*;

struct LOGCOLORSPACEW {
    DWORD lcsSignature;
    DWORD lcsVersion;
    DWORD lcsSize;
    LCSCSTYPE lcsCSType;
    LCSGAMUTMATCH lcsIntent;
    CIEXYZTRIPLE lcsEndpoints;
    DWORD lcsGammaRed;
    DWORD lcsGammaGreen;
    DWORD lcsGammaBlue;
    WCHAR[MAX_PATH] lcsFilename = 0;
}
alias LPLOGCOLORSPACEW = LOGCOLORSPACEW*;

alias COLOR16 = USHORT;
struct TRIVERTEX {
    LONG x;
    LONG y;
    COLOR16 Red;
    COLOR16 Green;
    COLOR16 Blue;
    COLOR16 Alpha;
}
alias PTRIVERTEX = TRIVERTEX*, LPTRIVERTEX = TRIVERTEX*;

struct EMRGLSRECORD {
    EMR emr;
    DWORD cbData;
    BYTE[1] Data;
}
alias PEMRGLSRECORD = EMRGLSRECORD*;

struct EMRGLSBOUNDEDRECORD {
    EMR emr;
    RECTL rclBounds;
    DWORD cbData;
    BYTE[1] Data;
}
alias PEMRGLSBOUNDEDRECORD = EMRGLSBOUNDEDRECORD*;

struct EMRPIXELFORMAT {
    EMR emr;
    PIXELFORMATDESCRIPTOR pfd;
}
alias PEMRPIXELFORMAT = EMRPIXELFORMAT*;

struct EMRCREATECOLORSPACE {
    EMR emr;
    DWORD ihCS;
    LOGCOLORSPACEA lcs; // ANSI version
}
alias PEMRCREATECOLORSPACE = EMRCREATECOLORSPACE*;

struct EMRSETCOLORSPACE {
    EMR emr;
    DWORD ihCS;
}
alias PEMRSETCOLORSPACE = EMRSETCOLORSPACE*;
alias EMRSELECTCOLORSPACE = EMRSETCOLORSPACE;
alias PEMRSELECTCOLORSPACE = EMRSELECTCOLORSPACE*;
alias EMRDELETECOLORSPACE = EMRSETCOLORSPACE;
alias PEMRDELETECOLORSPACE = EMRDELETECOLORSPACE*;

static if (_WIN32_WINNT >= 0x500) {

    struct EMREXTESCAPE {
        EMR emr;
        INT iEscape;
        INT cbEscData;
        BYTE[1] EscData;
    }
    alias PEMREXTESCAPE = EMREXTESCAPE*;
    alias EMRDRAWESCAPE = EMREXTESCAPE;
    alias PEMRDRAWESCAPE = EMRDRAWESCAPE*;

    struct EMRNAMEDESCAPE {
        EMR emr;
        INT iEscape;
        INT cbDriver;
        INT cbEscData;
        BYTE[1] EscData;
    }
    alias PEMRNAMEDESCAPE = EMRNAMEDESCAPE*;

    struct EMRSETICMPROFILE {
        EMR emr;
        DWORD dwFlags;
        DWORD cbName;
        DWORD cbData;
        BYTE[1] Data;
    }
    alias PEMRSETICMPROFILE = EMRSETICMPROFILE*;
    alias EMRSETICMPROFILEA = EMRSETICMPROFILE;
    alias PEMRSETICMPROFILEA = EMRSETICMPROFILEA*;
    alias EMRSETICMPROFILEW = EMRSETICMPROFILE;
    alias PEMRSETICMPROFILEW = EMRSETICMPROFILEW*;

    struct EMRCREATECOLORSPACEW {
        EMR emr;
        DWORD ihCS;
        LOGCOLORSPACEW lcs;
        DWORD dwFlags;
        DWORD cbData;
        BYTE[1] Data;
    }
    alias PEMRCREATECOLORSPACEW = EMRCREATECOLORSPACEW*;

    struct EMRCOLORMATCHTOTARGET {
        EMR emr;
        DWORD dwAction;
        DWORD dwFlags;
        DWORD cbName;
        DWORD cbData;
        BYTE[1] Data;
    }
    alias PEMRCOLORMATCHTOTARGET = EMRCOLORMATCHTOTARGET*;

    struct EMRCOLORCORRECTPALETTE {
        EMR emr;
        DWORD ihPalette;
        DWORD nFirstEntry;
        DWORD nPalEntries;
        DWORD nReserved;
    }
    alias PEMRCOLORCORRECTPALETTE = EMRCOLORCORRECTPALETTE*;

    struct EMRALPHABLEND {
        EMR emr;
        RECTL rclBounds;
        LONG xDest;
        LONG yDest;
        LONG cxDest;
        LONG cyDest;
        DWORD dwRop;
        LONG xSrc;
        LONG ySrc;
        XFORM xformSrc;
        COLORREF crBkColorSrc;
        DWORD iUsageSrc;
        DWORD offBmiSrc;
        DWORD cbBmiSrc;
        DWORD offBitsSrc;
        DWORD cbBitsSrc;
        LONG cxSrc;
        LONG cySrc;
    }
    alias PEMRALPHABLEND = EMRALPHABLEND*;

    struct EMRGRADIENTFILL {
        EMR emr;
        RECTL rclBounds;
        DWORD nVer;
        DWORD nTri;
        ULONG ulMode;
        TRIVERTEX[1] Ver;
    }
    alias PEMRGRADIENTFILL = EMRGRADIENTFILL*;

    struct EMRTRANSPARENTBLT {
        EMR emr;
        RECTL rclBounds;
        LONG xDest;
        LONG yDest;
        LONG cxDest;
        LONG cyDest;
        DWORD dwRop;
        LONG xSrc;
        LONG ySrc;
        XFORM xformSrc;
        COLORREF crBkColorSrc;
        DWORD iUsageSrc;
        DWORD offBmiSrc;
        DWORD cbBmiSrc;
        DWORD offBitsSrc;
        DWORD cbBitsSrc;
        LONG cxSrc;
        LONG cySrc;
    }
    alias PEMRTRANSPARENTBLT = EMRTRANSPARENTBLT*;
}

struct EMRCREATEDIBPATTERNBRUSHPT {
    EMR emr;
    DWORD ihBrush;
    DWORD iUsage;
    DWORD offBmi;
    DWORD cbBmi;
    DWORD offBits;
    DWORD cbBits;
}
alias PEMRCREATEDIBPATTERNBRUSHPT = EMRCREATEDIBPATTERNBRUSHPT*;

struct EMRCREATEMONOBRUSH {
    EMR emr;
    DWORD ihBrush;
    DWORD iUsage;
    DWORD offBmi;
    DWORD cbBmi;
    DWORD offBits;
    DWORD cbBits;
}
alias PEMRCREATEMONOBRUSH = EMRCREATEMONOBRUSH*;

struct PALETTEENTRY {
    BYTE peRed;
    BYTE peGreen;
    BYTE peBlue;
    BYTE peFlags;
}
alias PPALETTEENTRY = PALETTEENTRY*, LPPALETTEENTRY = PALETTEENTRY*;

struct LOGPALETTE {
    WORD palVersion;
    WORD palNumEntries;
    PALETTEENTRY[1] palPalEntry;
}
alias PLOGPALETTE = LOGPALETTE*, NPLOGPALETTE = LOGPALETTE*, LPLOGPALETTE = LOGPALETTE*;

struct EMRCREATEPALETTE {
    EMR emr;
    DWORD ihPal;
    LOGPALETTE lgpl;
}
alias PEMRCREATEPALETTE = EMRCREATEPALETTE*;

struct EMRCREATEPEN {
    EMR emr;
    DWORD ihPen;
    LOGPEN lopn;
}
alias PEMRCREATEPEN = EMRCREATEPEN*;

struct EMRELLIPSE {
    EMR emr;
    RECTL rclBox;
}
alias PEMRELLIPSE = EMRELLIPSE*;

alias EMRRECTANGLE = EMRELLIPSE;
alias PEMRRECTANGLE = EMRRECTANGLE*;

struct EMREOF {
    EMR emr;
    DWORD nPalEntries;
    DWORD offPalEntries;
    DWORD nSizeLast;
}
alias PEMREOF = EMREOF*;

struct EMREXCLUDECLIPRECT {
    EMR emr;
    RECTL rclClip;
}
alias PEMREXCLUDECLIPRECT = EMREXCLUDECLIPRECT*;
alias EMRINTERSECTCLIPRECT = EMREXCLUDECLIPRECT;
alias PEMRINTERSECTCLIPRECT = EMRINTERSECTCLIPRECT*;

struct EMREXTCREATEFONTINDIRECTW {
    EMR emr;
    DWORD ihFont;
    EXTLOGFONTW elfw;
}
alias PEMREXTCREATEFONTINDIRECTW = EMREXTCREATEFONTINDIRECTW*;

struct EXTLOGPEN {
    UINT elpPenStyle;
    UINT elpWidth;
    UINT elpBrushStyle;
    COLORREF elpColor;
    ULONG_PTR elpHatch;
    DWORD elpNumEntries;
    DWORD[1] elpStyleEntry;
}
alias PEXTLOGPEN = EXTLOGPEN*, NPEXTLOGPEN = EXTLOGPEN*, LPEXTLOGPEN = EXTLOGPEN*;

struct EXTLOGPEN32 {
    UINT elpPenStyle;
    UINT elpWidth;
    UINT elpBrushStyle;
    COLORREF elpColor;
    ULONG elpHatch;
    DWORD elpNumEntries;
    DWORD[1] elpStyleEntry;
}
alias PEXTLOGPEN32 = EXTLOGPEN32*, NPEXTLOGPEN32 = EXTLOGPEN32*, LPEXTLOGPEN32 = EXTLOGPEN32*;

struct EMREXTCREATEPEN {
    EMR emr;
    DWORD ihPen;
    DWORD offBmi;
    DWORD cbBmi;
    DWORD offBits;
    DWORD cbBits;
    EXTLOGPEN32 elp;
}
alias PEMREXTCREATEPEN = EMREXTCREATEPEN*;

struct EMREXTFLOODFILL {
    EMR emr;
    POINTL ptlStart;
    COLORREF crColor;
    DWORD iMode;
}
alias PEMREXTFLOODFILL = EMREXTFLOODFILL*;

struct EMREXTSELECTCLIPRGN {
    EMR emr;
    DWORD cbRgnData;
    DWORD iMode;
    BYTE [1]RgnData;
}
alias PEMREXTSELECTCLIPRGN = EMREXTSELECTCLIPRGN*;

struct EMRTEXT {
    POINTL ptlReference;
    DWORD nChars;
    DWORD offString;
    DWORD fOptions;
    RECTL rcl;
    DWORD offDx;
}
alias PEMRTEXT = EMRTEXT*;

struct EMREXTTEXTOUTA {
    EMR emr;
    RECTL rclBounds;
    DWORD iGraphicsMode;
    FLOAT exScale;
    FLOAT eyScale;
    EMRTEXT emrtext;
}
alias PEMREXTTEXTOUTA = EMREXTTEXTOUTA*;
alias EMREXTTEXTOUTW = EMREXTTEXTOUTA;
alias PEMREXTTEXTOUTW = EMREXTTEXTOUTW*;

struct EMRFILLPATH {
    EMR emr;
    RECTL rclBounds;
}
alias PEMRFILLPATH = EMRFILLPATH*;

alias EMRSTROKEANDFILLPATH = EMRFILLPATH;
alias PEMRSTROKEANDFILLPATH = EMRSTROKEANDFILLPATH*;

alias EMRSTROKEPATH = EMRFILLPATH;
alias PEMRSTROKEPATH = EMRSTROKEPATH*;

struct EMRFILLRGN {
    EMR emr;
    RECTL rclBounds;
    DWORD cbRgnData;
    DWORD ihBrush;
    BYTE[1] RgnData;
}
alias PEMRFILLRGN = EMRFILLRGN*;

struct EMRFORMAT {
    DWORD dSignature;
    DWORD nVersion;
    DWORD cbData;
    DWORD offData;
}
alias PEMRFORMAT = EMRFORMAT*;

struct EMRFRAMERGN {
    EMR emr;
    RECTL rclBounds;
    DWORD cbRgnData;
    DWORD ihBrush;
    SIZEL szlStroke;
    BYTE[1] RgnData;
}
alias PEMRFRAMERGN = EMRFRAMERGN*;

struct EMRGDICOMMENT {
    EMR emr;
    DWORD cbData;
    BYTE[1] Data;
}
alias PEMRGDICOMMENT = EMRGDICOMMENT*;

struct EMRINVERTRGN {
    EMR emr;
    RECTL rclBounds;
    DWORD cbRgnData;
    BYTE[1] RgnData;
}
alias PEMRINVERTRGN = EMRINVERTRGN*;
alias EMRPAINTRGN = EMRINVERTRGN;
alias PEMRPAINTRGN = EMRPAINTRGN*;

struct EMRLINETO {
    EMR emr;
    POINTL ptl;
}
alias PEMRLINETO = EMRLINETO*;
alias EMRMOVETOEX = EMRLINETO;
alias PEMRMOVETOEX = EMRMOVETOEX*;

struct EMRMASKBLT {
    EMR emr;
    RECTL rclBounds;
    LONG xDest;
    LONG yDest;
    LONG cxDest;
    LONG cyDest;
    DWORD dwRop;
    LONG xSrc;
    LONG ySrc;
    XFORM xformSrc;
    COLORREF crBkColorSrc;
    DWORD iUsageSrc;
    DWORD offBmiSrc;
    DWORD cbBmiSrc;
    DWORD offBitsSrc;
    DWORD cbBitsSrc;
    LONG xMask;
    LONG yMask;
    DWORD iUsageMask;
    DWORD offBmiMask;
    DWORD cbBmiMask;
    DWORD offBitsMask;
    DWORD cbBitsMask;
}
alias PEMRMASKBLT = EMRMASKBLT*;

struct EMRMODIFYWORLDTRANSFORM {
    EMR emr;
    XFORM xform;
    DWORD iMode;
}
alias PEMRMODIFYWORLDTRANSFORM = EMRMODIFYWORLDTRANSFORM*;

struct EMROFFSETCLIPRGN {
    EMR emr;
    POINTL ptlOffset;
}
alias PEMROFFSETCLIPRGN = EMROFFSETCLIPRGN*;

struct EMRPLGBLT {
    EMR emr;
    RECTL rclBounds;
    POINTL[3] aptlDest;
    LONG xSrc;
    LONG ySrc;
    LONG cxSrc;
    LONG cySrc;
    XFORM xformSrc;
    COLORREF crBkColorSrc;
    DWORD iUsageSrc;
    DWORD offBmiSrc;
    DWORD cbBmiSrc;
    DWORD offBitsSrc;
    DWORD cbBitsSrc;
    LONG xMask;
    LONG yMask;
    DWORD iUsageMask;
    DWORD offBmiMask;
    DWORD cbBmiMask;
    DWORD offBitsMask;
    DWORD cbBitsMask;
}
alias PEMRPLGBLT = EMRPLGBLT*;

struct EMRPOLYDRAW {
    EMR emr;
    RECTL rclBounds;
    DWORD cptl;
    POINTL[1] aptl;
    BYTE[1] abTypes;
}
alias PEMRPOLYDRAW = EMRPOLYDRAW*;

struct EMRPOLYDRAW16 {
    EMR emr;
    RECTL rclBounds;
    DWORD cpts;
    POINTS[1] apts;
    BYTE[1] abTypes;
}
alias PEMRPOLYDRAW16 = EMRPOLYDRAW16*;

struct EMRPOLYLINE {
    EMR emr;
    RECTL rclBounds;
    DWORD cptl;
    POINTL[1] aptl;
}
alias PEMRPOLYLINE = EMRPOLYLINE*;
alias EMRPOLYBEZIER = EMRPOLYLINE;
alias PEMRPOLYBEZIER = EMRPOLYBEZIER*;
alias EMRPOLYGON = EMRPOLYLINE;
alias PEMRPOLYGON = EMRPOLYGON*;
alias EMRPOLYBEZIERTO = EMRPOLYLINE;
alias PEMRPOLYBEZIERTO = EMRPOLYBEZIERTO*;
alias EMRPOLYLINETO = EMRPOLYLINE;
alias PEMRPOLYLINETO = EMRPOLYLINETO*;

struct EMRPOLYLINE16 {
    EMR emr;
    RECTL rclBounds;
    DWORD cpts;
    POINTS[1] apts;
}
alias PEMRPOLYLINE16 = EMRPOLYLINE16*;
alias EMRPOLYBEZIER16 = EMRPOLYLINE16;
alias PEMRPOLYBEZIER16 = EMRPOLYBEZIER16*;
alias EMRPOLYGON16 = EMRPOLYLINE16;
alias PEMRPOLYGON16 = EMRPOLYGON16*;
alias EMRPOLYBEZIERTO16 = EMRPOLYLINE16;
alias PEMRPOLYBEZIERTO16 = EMRPOLYBEZIERTO16*;
alias EMRPOLYLINETO16 = EMRPOLYLINE16;
alias PEMRPOLYLINETO16 = EMRPOLYLINETO16*;

struct EMRPOLYPOLYLINE {
    EMR emr;
    RECTL rclBounds;
    DWORD nPolys;
    DWORD cptl;
    DWORD[1] aPolyCounts;
    POINTL[1] aptl;
}
alias PEMRPOLYPOLYLINE = EMRPOLYPOLYLINE*;
alias EMRPOLYPOLYGON = EMRPOLYPOLYLINE;
alias PEMRPOLYPOLYGON = EMRPOLYPOLYGON*;

struct EMRPOLYPOLYLINE16 {
    EMR emr;
    RECTL rclBounds;
    DWORD nPolys;
    DWORD cpts;
    DWORD[1] aPolyCounts;
    POINTS[1] apts;
}
alias PEMRPOLYPOLYLINE16 = EMRPOLYPOLYLINE16*;
alias EMRPOLYPOLYGON16 = EMRPOLYPOLYLINE16;
alias PEMRPOLYPOLYGON16 = EMRPOLYPOLYGON16*;

struct EMRPOLYTEXTOUTA {
    EMR emr;
    RECTL rclBounds;
    DWORD iGraphicsMode;
    FLOAT exScale;
    FLOAT eyScale;
    LONG cStrings;
    EMRTEXT[1] aemrtext;
}
alias PEMRPOLYTEXTOUTA = EMRPOLYTEXTOUTA*;
alias EMRPOLYTEXTOUTW = EMRPOLYTEXTOUTA;
alias PEMRPOLYTEXTOUTW = EMRPOLYTEXTOUTW*;

struct EMRRESIZEPALETTE {
    EMR emr;
    DWORD ihPal;
    DWORD cEntries;
}
alias PEMRRESIZEPALETTE = EMRRESIZEPALETTE*;

struct EMRRESTOREDC {
    EMR emr;
    LONG iRelative;
}
alias PEMRRESTOREDC = EMRRESTOREDC*;

struct EMRROUNDRECT {
    EMR emr;
    RECTL rclBox;
    SIZEL szlCorner;
}
alias PEMRROUNDRECT = EMRROUNDRECT*;

struct EMRSCALEVIEWPORTEXTEX {
    EMR emr;
    LONG xNum;
    LONG xDenom;
    LONG yNum;
    LONG yDenom;
}
alias PEMRSCALEVIEWPORTEXTEX = EMRSCALEVIEWPORTEXTEX*;
alias EMRSCALEWINDOWEXTEX = EMRSCALEVIEWPORTEXTEX;
alias PEMRSCALEWINDOWEXTEX = EMRSCALEWINDOWEXTEX*;

struct EMRSELECTOBJECT {
    EMR emr;
    DWORD ihObject;
}
alias PEMRSELECTOBJECT = EMRSELECTOBJECT*;
alias EMRDELETEOBJECT = EMRSELECTOBJECT;
alias PEMRDELETEOBJECT = EMRDELETEOBJECT*;

struct EMRSELECTPALETTE {
    EMR emr;
    DWORD ihPal;
}
alias PEMRSELECTPALETTE = EMRSELECTPALETTE*;

struct EMRSETARCDIRECTION {
    EMR emr;
    DWORD iArcDirection;
}
alias PEMRSETARCDIRECTION = EMRSETARCDIRECTION*;

struct EMRSETTEXTCOLOR {
    EMR emr;
    COLORREF crColor;
}
alias PEMRSETTEXTCOLOR = EMRSETTEXTCOLOR*;
alias EMRSETBKCOLOR = EMRSETTEXTCOLOR;
alias PEMRSETBKCOLOR = EMRSETBKCOLOR*;

struct EMRSETCOLORADJUSTMENT {
    EMR emr;
    COLORADJUSTMENT ColorAdjustment;
}
alias PEMRSETCOLORADJUSTMENT = EMRSETCOLORADJUSTMENT*;

struct EMRSETDIBITSTODEVICE {
    EMR emr;
    RECTL rclBounds;
    LONG xDest;
    LONG yDest;
    LONG xSrc;
    LONG ySrc;
    LONG cxSrc;
    LONG cySrc;
    DWORD offBmiSrc;
    DWORD cbBmiSrc;
    DWORD offBitsSrc;
    DWORD cbBitsSrc;
    DWORD iUsageSrc;
    DWORD iStartScan;
    DWORD cScans;
}
alias PEMRSETDIBITSTODEVICE = EMRSETDIBITSTODEVICE*;

struct EMRSETMAPPERFLAGS {
    EMR emr;
    DWORD dwFlags;
}
alias PEMRSETMAPPERFLAGS = EMRSETMAPPERFLAGS*;

struct EMRSETMITERLIMIT {
    EMR emr;
    FLOAT eMiterLimit;
}
alias PEMRSETMITERLIMIT = EMRSETMITERLIMIT*;

struct EMRSETPALETTEENTRIES {
    EMR emr;
    DWORD ihPal;
    DWORD iStart;
    DWORD cEntries;
    PALETTEENTRY[1] aPalEntries;
}
alias PEMRSETPALETTEENTRIES = EMRSETPALETTEENTRIES*;

struct EMRSETPIXELV {
    EMR emr;
    POINTL ptlPixel;
    COLORREF crColor;
}
alias PEMRSETPIXELV = EMRSETPIXELV*;

struct EMRSETVIEWPORTEXTEX {
    EMR emr;
    SIZEL szlExtent;
}
alias PEMRSETVIEWPORTEXTEX = EMRSETVIEWPORTEXTEX*;
alias EMRSETWINDOWEXTEX = EMRSETVIEWPORTEXTEX;
alias PEMRSETWINDOWEXTEX = EMRSETWINDOWEXTEX*;

struct EMRSETVIEWPORTORGEX {
    EMR emr;
    POINTL ptlOrigin;
}
alias PEMRSETVIEWPORTORGEX = EMRSETVIEWPORTORGEX*;
alias EMRSETWINDOWORGEX = EMRSETVIEWPORTORGEX;
alias PEMRSETWINDOWORGEX = EMRSETWINDOWORGEX*;
alias EMRSETBRUSHORGEX = EMRSETVIEWPORTORGEX;
alias PEMRSETBRUSHORGEX = EMRSETBRUSHORGEX*;

struct EMRSETWORLDTRANSFORM {
    EMR emr;
    XFORM xform;
}
alias PEMRSETWORLDTRANSFORM = EMRSETWORLDTRANSFORM*;

struct EMRSTRETCHBLT {
    EMR emr;
    RECTL rclBounds;
    LONG xDest;
    LONG yDest;
    LONG cxDest;
    LONG cyDest;
    DWORD dwRop;
    LONG xSrc;
    LONG ySrc;
    XFORM xformSrc;
    COLORREF crBkColorSrc;
    DWORD iUsageSrc;
    DWORD offBmiSrc;
    DWORD cbBmiSrc;
    DWORD offBitsSrc;
    DWORD cbBitsSrc;
    LONG cxSrc;
    LONG cySrc;
}
alias PEMRSTRETCHBLT = EMRSTRETCHBLT*;

struct EMRSTRETCHDIBITS {
    EMR emr;
    RECTL rclBounds;
    LONG xDest;
    LONG yDest;
    LONG xSrc;
    LONG ySrc;
    LONG cxSrc;
    LONG cySrc;
    DWORD offBmiSrc;
    DWORD cbBmiSrc;
    DWORD offBitsSrc;
    DWORD cbBitsSrc;
    DWORD iUsageSrc;
    DWORD dwRop;
    LONG cxDest;
    LONG cyDest;
}
alias PEMRSTRETCHDIBITS = EMRSTRETCHDIBITS*;

struct EMRABORTPATH {
    EMR emr;
}
alias PEMRABORTPATH = EMRABORTPATH*;
alias EMRBEGINPATH = EMRABORTPATH;
alias PEMRBEGINPATH = EMRBEGINPATH*;
alias EMRENDPATH = EMRABORTPATH;
alias PEMRENDPATH = EMRENDPATH*;
alias EMRCLOSEFIGURE = EMRABORTPATH;
alias PEMRCLOSEFIGURE = EMRCLOSEFIGURE*;
alias EMRFLATTENPATH = EMRABORTPATH;
alias PEMRFLATTENPATH = EMRFLATTENPATH*;
alias EMRWIDENPATH = EMRABORTPATH;
alias PEMRWIDENPATH = EMRWIDENPATH*;
alias EMRSETMETARGN = EMRABORTPATH;
alias PEMRSETMETARGN = EMRSETMETARGN*;
alias EMRSAVEDC = EMRABORTPATH;
alias PEMRSAVEDC = EMRSAVEDC*;
alias EMRREALIZEPALETTE = EMRABORTPATH;
alias PEMRREALIZEPALETTE = EMRREALIZEPALETTE*;

struct EMRSELECTCLIPPATH {
    EMR emr;
    DWORD iMode;
}
alias PEMRSELECTCLIPPATH = EMRSELECTCLIPPATH*;
alias EMRSETBKMODE = EMRSELECTCLIPPATH;
alias PEMRSETBKMODE = EMRSETBKMODE*;
alias EMRSETMAPMODE = EMRSELECTCLIPPATH;
alias PEMRSETMAPMODE = EMRSETMAPMODE*;
alias EMRSETPOLYFILLMODE = EMRSELECTCLIPPATH;
alias PEMRSETPOLYFILLMODE = EMRSETPOLYFILLMODE*;
alias EMRSETROP2 = EMRSELECTCLIPPATH;
alias PEMRSETROP2 = EMRSETROP2*;
alias EMRSETSTRETCHBLTMODE = EMRSELECTCLIPPATH;
alias PEMRSETSTRETCHBLTMODE = EMRSETSTRETCHBLTMODE*;
alias EMRSETICMMODE = EMRSELECTCLIPPATH;
alias PEMRSETICMMODE = EMRSETICMMODE*;
alias EMRSETTEXTALIGN = EMRSELECTCLIPPATH;
alias PEMRSETTEXTALIGN = EMRSETTEXTALIGN*;
alias EMRENABLEICM = EMRSELECTCLIPPATH;
alias PEMRENABLEICM = EMRENABLEICM*;
static if (_WIN32_WINNT >= 0x500) {
    alias EMRSETLAYOUT = EMRSELECTCLIPPATH;
    alias PEMRSETLAYOUT = EMRSETLAYOUT*;
}

align(2):
struct METAHEADER {
align(2):
    WORD mtType;
    WORD mtHeaderSize;
    WORD mtVersion;
    DWORD mtSize;
    WORD mtNoObjects;
    DWORD mtMaxRecord;
    WORD mtNoParameters;
}
alias PMETAHEADER = METAHEADER*;
alias LPMETAHEADER = METAHEADER*;

align:

struct ENHMETAHEADER {
    DWORD iType = EMR_HEADER;
    DWORD nSize = ENHMETAHEADER.sizeof;
    RECTL rclBounds;
    RECTL rclFrame;
    DWORD dSignature = ENHMETA_SIGNATURE;
    DWORD nVersion;
    DWORD nBytes;
    DWORD nRecords;
    WORD nHandles;
    WORD sReserved;
    DWORD nDescription;
    DWORD offDescription;
    DWORD nPalEntries;
    SIZEL szlDevice;
    SIZEL szlMillimeters;
    DWORD cbPixelFormat;
    DWORD offPixelFormat;
    DWORD bOpenGL;
    static if (_WIN32_WINNT >= 0x500) {
        SIZEL szlMicrometers;
    }
}
alias PENHMETAHEADER = ENHMETAHEADER*, LPENHMETAHEADER = ENHMETAHEADER*;

struct METARECORD {
    DWORD rdSize;
    WORD rdFunction;
    WORD[1] rdParm;
}
alias PMETARECORD = METARECORD*;
alias LPMETARECORD = METARECORD*;

struct ENHMETARECORD {
    DWORD iType;
    DWORD nSize;
    DWORD[1] dParm;
}
alias PENHMETARECORD = ENHMETARECORD*, LPENHMETARECORD = ENHMETARECORD*;

// ---

struct HANDLETABLE {
    HGDIOBJ[1] objectHandle;
}
alias PHANDLETABLE = HANDLETABLE*, LPHANDLETABLE = HANDLETABLE*;

struct TEXTMETRICA {
    LONG tmHeight;
    LONG tmAscent;
    LONG tmDescent;
    LONG tmInternalLeading;
    LONG tmExternalLeading;
    LONG tmAveCharWidth;
    LONG tmMaxCharWidth;
    LONG tmWeight;
    LONG tmOverhang;
    LONG tmDigitizedAspectX;
    LONG tmDigitizedAspectY;
    BYTE tmFirstChar;
    BYTE tmLastChar;
    BYTE tmDefaultChar;
    BYTE tmBreakChar;
    BYTE tmItalic;
    BYTE tmUnderlined;
    BYTE tmStruckOut;
    BYTE tmPitchAndFamily;
    BYTE tmCharSet;
}
alias PTEXTMETRICA = TEXTMETRICA*, NPTEXTMETRICA = TEXTMETRICA*, LPTEXTMETRICA = TEXTMETRICA*;

struct TEXTMETRICW {
    LONG tmHeight;
    LONG tmAscent;
    LONG tmDescent;
    LONG tmInternalLeading;
    LONG tmExternalLeading;
    LONG tmAveCharWidth;
    LONG tmMaxCharWidth;
    LONG tmWeight;
    LONG tmOverhang;
    LONG tmDigitizedAspectX;
    LONG tmDigitizedAspectY;
    WCHAR tmFirstChar = 0;
    WCHAR tmLastChar = 0;
    WCHAR tmDefaultChar = 0;
    WCHAR tmBreakChar = 0;
    BYTE tmItalic;
    BYTE tmUnderlined;
    BYTE tmStruckOut;
    BYTE tmPitchAndFamily;
    BYTE tmCharSet;
}
alias PTEXTMETRICW = TEXTMETRICW*, NPTEXTMETRICW = TEXTMETRICW*, LPTEXTMETRICW = TEXTMETRICW*;

struct RGNDATAHEADER {
    DWORD dwSize;
    DWORD iType;
    DWORD nCount;
    DWORD nRgnSize;
    RECT rcBound;
}
alias PRGNDATAHEADER = RGNDATAHEADER*;

struct RGNDATA {
    RGNDATAHEADER rdh;
    char[1] Buffer = 0;
}
alias PRGNDATA = RGNDATA*, NPRGNDATA = RGNDATA*, LPRGNDATA = RGNDATA*;

/* for GetRandomRgn */
enum SYSRGN=4;
struct GCP_RESULTSA {
    DWORD lStructSize;
    LPSTR lpOutString;
    UINT* lpOrder;
    INT* lpDx;
    INT* lpCaretPos;
    LPSTR lpClass;
    LPWSTR lpGlyphs;
    UINT nGlyphs;
    UINT nMaxFit;
}
alias LPGCP_RESULTSA = GCP_RESULTSA*;

struct GCP_RESULTSW {
    DWORD lStructSize;
    LPWSTR lpOutString;
    UINT* lpOrder;
    INT* lpDx;
    INT* lpCaretPos;
    LPWSTR lpClass;
    LPWSTR lpGlyphs;
    UINT nGlyphs;
    UINT nMaxFit;
}
alias LPGCP_RESULTSW = GCP_RESULTSW*;

struct GLYPHMETRICS {
    UINT gmBlackBoxX;
    UINT gmBlackBoxY;
    POINT gmptGlyphOrigin;
    short gmCellIncX;
    short gmCellIncY;
}
alias LPGLYPHMETRICS = GLYPHMETRICS*;

static if (_WIN32_WINNT >= 0x500) {
    struct WCRANGE {
        WCHAR  wcLow = 0;
        USHORT cGlyphs;
    }
    alias PWCRANGE = WCRANGE*, LPWCRANGE = WCRANGE*;

    struct GLYPHSET {
        DWORD cbThis;
        DWORD flAccel;
        DWORD cGlyphsSupported;
        DWORD cRanges;
        WCRANGE[1] ranges;
    }
    alias PGLYPHSET = GLYPHSET*, LPGLYPHSET = GLYPHSET*;

enum DWORD GS_8BIT_INDICES = 0x00000001;
}

struct KERNINGPAIR {
    WORD wFirst;
    WORD wSecond;
    int iKernAmount;
}
alias LPKERNINGPAIR = KERNINGPAIR*;

struct FIXED {
    WORD fract;
    short value;
}

struct MAT2 {
    FIXED eM11;
    FIXED eM12;
    FIXED eM21;
    FIXED eM22;
}
alias LPMAT2 = MAT2*;

struct OUTLINETEXTMETRICA {
    UINT otmSize;
    TEXTMETRICA otmTextMetrics;
    BYTE otmFiller;
    PANOSE otmPanoseNumber;
    UINT otmfsSelection;
    UINT otmfsType;
    int otmsCharSlopeRise;
    int otmsCharSlopeRun;
    int otmItalicAngle;
    UINT otmEMSquare;
    int otmAscent;
    int otmDescent;
    UINT otmLineGap;
    UINT otmsCapEmHeight;
    UINT otmsXHeight;
    RECT otmrcFontBox;
    int otmMacAscent;
    int otmMacDescent;
    UINT otmMacLineGap;
    UINT otmusMinimumPPEM;
    POINT otmptSubscriptSize;
    POINT otmptSubscriptOffset;
    POINT otmptSuperscriptSize;
    POINT otmptSuperscriptOffset;
    UINT otmsStrikeoutSize;
    int otmsStrikeoutPosition;
    int otmsUnderscoreSize;
    int otmsUnderscorePosition;
    PSTR otmpFamilyName;
    PSTR otmpFaceName;
    PSTR otmpStyleName;
    PSTR otmpFullName;
}
alias POUTLINETEXTMETRICA = OUTLINETEXTMETRICA*, NPOUTLINETEXTMETRICA = OUTLINETEXTMETRICA*, LPOUTLINETEXTMETRICA = OUTLINETEXTMETRICA*;

struct OUTLINETEXTMETRICW {
    UINT otmSize;
    TEXTMETRICW otmTextMetrics;
    BYTE otmFiller;
    PANOSE otmPanoseNumber;
    UINT otmfsSelection;
    UINT otmfsType;
    int otmsCharSlopeRise;
    int otmsCharSlopeRun;
    int otmItalicAngle;
    UINT otmEMSquare;
    int otmAscent;
    int otmDescent;
    UINT otmLineGap;
    UINT otmsCapEmHeight;
    UINT otmsXHeight;
    RECT otmrcFontBox;
    int otmMacAscent;
    int otmMacDescent;
    UINT otmMacLineGap;
    UINT otmusMinimumPPEM;
    POINT otmptSubscriptSize;
    POINT otmptSubscriptOffset;
    POINT otmptSuperscriptSize;
    POINT otmptSuperscriptOffset;
    UINT otmsStrikeoutSize;
    int otmsStrikeoutPosition;
    int otmsUnderscoreSize;
    int otmsUnderscorePosition;
    PSTR otmpFamilyName;
    PSTR otmpFaceName;
    PSTR otmpStyleName;
    PSTR otmpFullName;
}
alias POUTLINETEXTMETRICW = OUTLINETEXTMETRICW*, NPOUTLINETEXTMETRICW = OUTLINETEXTMETRICW*, LPOUTLINETEXTMETRICW = OUTLINETEXTMETRICW*;

struct RASTERIZER_STATUS {
    short nSize;
    short wFlags;
    short nLanguageID;
}
alias LPRASTERIZER_STATUS = RASTERIZER_STATUS*;

struct POLYTEXTA {
    int x;
    int y;
    UINT n;
    LPCSTR lpstr;
    UINT uiFlags;
    RECT rcl;
    int* pdx;
}
alias PPOLYTEXTA = POLYTEXTA*, NPPOLYTEXTA = POLYTEXTA*, LPPOLYTEXTA = POLYTEXTA*;

struct POLYTEXTW {
    int x;
    int y;
    UINT n;
    LPCWSTR lpstr;
    UINT uiFlags;
    RECT rcl;
    int* pdx;
}
alias PPOLYTEXTW = POLYTEXTW*, NPPOLYTEXTW = POLYTEXTW*, LPPOLYTEXTW = POLYTEXTW*;

struct PIXELFORMATDESCRIPTOR {
    WORD nSize;
    WORD nVersion;
    DWORD dwFlags;
    BYTE iPixelType;
    BYTE cColorBits;
    BYTE cRedBits;
    BYTE cRedShift;
    BYTE cGreenBits;
    BYTE cGreenShift;
    BYTE cBlueBits;
    BYTE cBlueShift;
    BYTE cAlphaBits;
    BYTE cAlphaShift;
    BYTE cAccumBits;
    BYTE cAccumRedBits;
    BYTE cAccumGreenBits;
    BYTE cAccumBlueBits;
    BYTE cAccumAlphaBits;
    BYTE cDepthBits;
    BYTE cStencilBits;
    BYTE cAuxBuffers;
    BYTE iLayerType;
    BYTE bReserved;
    DWORD dwLayerMask;
    DWORD dwVisibleMask;
    DWORD dwDamageMask;
}
alias PPIXELFORMATDESCRIPTOR = PIXELFORMATDESCRIPTOR*, LPPIXELFORMATDESCRIPTOR = PIXELFORMATDESCRIPTOR*;

struct METAFILEPICT {
    LONG mm;
    LONG xExt;
    LONG yExt;
    HMETAFILE hMF;
}
alias LPMETAFILEPICT = METAFILEPICT*;

struct LOCALESIGNATURE {
    DWORD[4] lsUsb;
    DWORD[2] lsCsbDefault;
    DWORD[2] lsCsbSupported;
}
alias PLOCALESIGNATURE = LOCALESIGNATURE*, LPLOCALESIGNATURE = LOCALESIGNATURE*;

alias LCSTYPE = LONG; /* What this for? */

align(4):
struct NEWTEXTMETRICA {
    LONG tmHeight;
    LONG tmAscent;
    LONG tmDescent;
    LONG tmInternalLeading;
    LONG tmExternalLeading;
    LONG tmAveCharWidth;
    LONG tmMaxCharWidth;
    LONG tmWeight;
    LONG tmOverhang;
    LONG tmDigitizedAspectX;
    LONG tmDigitizedAspectY;
    BYTE tmFirstChar;
    BYTE tmLastChar;
    BYTE tmDefaultChar;
    BYTE tmBreakChar;
    BYTE tmItalic;
    BYTE tmUnderlined;
    BYTE tmStruckOut;
    BYTE tmPitchAndFamily;
    BYTE tmCharSet;
    DWORD ntmFlags;
    UINT ntmSizeEM;
    UINT ntmCellHeight;
    UINT ntmAvgWidth;
}
alias PNEWTEXTMETRICA = NEWTEXTMETRICA*, NPNEWTEXTMETRICA = NEWTEXTMETRICA*, LPNEWTEXTMETRICA = NEWTEXTMETRICA*;

struct NEWTEXTMETRICW {
    LONG tmHeight;
    LONG tmAscent;
    LONG tmDescent;
    LONG tmInternalLeading;
    LONG tmExternalLeading;
    LONG tmAveCharWidth;
    LONG tmMaxCharWidth;
    LONG tmWeight;
    LONG tmOverhang;
    LONG tmDigitizedAspectX;
    LONG tmDigitizedAspectY;
    WCHAR tmFirstChar = 0;
    WCHAR tmLastChar = 0;
    WCHAR tmDefaultChar = 0;
    WCHAR tmBreakChar = 0;
    BYTE tmItalic;
    BYTE tmUnderlined;
    BYTE tmStruckOut;
    BYTE tmPitchAndFamily;
    BYTE tmCharSet;
    DWORD ntmFlags;
    UINT ntmSizeEM;
    UINT ntmCellHeight;
    UINT ntmAvgWidth;
}
alias PNEWTEXTMETRICW = NEWTEXTMETRICW*, NPNEWTEXTMETRICW = NEWTEXTMETRICW*, LPNEWTEXTMETRICW = NEWTEXTMETRICW*;

align:
struct NEWTEXTMETRICEXA {
    NEWTEXTMETRICA ntmTm;
    FONTSIGNATURE ntmFontSig;
}

struct NEWTEXTMETRICEXW {
    NEWTEXTMETRICW ntmTm;
    FONTSIGNATURE ntmFontSig;
}

struct PELARRAY {
    LONG paXCount;
    LONG paYCount;
    LONG paXExt;
    LONG paYExt;
    BYTE paRGBs;
}
alias PPELARRAY = PELARRAY*, NPPELARRAY = PELARRAY*, LPPELARRAY = PELARRAY*;

struct ENUMLOGFONTA {
    LOGFONTA elfLogFont;
    BYTE[LF_FULLFACESIZE] elfFullName;
    BYTE[LF_FACESIZE] elfStyle;
}
alias LPENUMLOGFONTA = ENUMLOGFONTA*;

struct ENUMLOGFONTW {
    LOGFONTW elfLogFont;
    WCHAR[LF_FULLFACESIZE] elfFullName = 0;
    WCHAR[LF_FACESIZE] elfStyle = 0;
}
alias LPENUMLOGFONTW = ENUMLOGFONTW*;

struct ENUMLOGFONTEXA {
    LOGFONTA elfLogFont;
    BYTE[LF_FULLFACESIZE] elfFullName;
    BYTE[LF_FACESIZE] elfStyle;
    BYTE[LF_FACESIZE] elfScript;
}
alias LPENUMLOGFONTEXA = ENUMLOGFONTEXA*;

struct ENUMLOGFONTEXW {
    LOGFONTW elfLogFont;
    WCHAR[LF_FULLFACESIZE] elfFullName = 0;
    WCHAR[LF_FACESIZE] elfStyle = 0;
    WCHAR[LF_FACESIZE] elfScript = 0;
}
alias LPENUMLOGFONTEXW = ENUMLOGFONTEXW*;

struct POINTFX {
    FIXED x;
    FIXED y;
}
alias LPPOINTFX = POINTFX*;

struct TTPOLYCURVE {
    WORD wType;
    WORD cpfx;
    POINTFX[1] apfx;
}
alias LPTTPOLYCURVE = TTPOLYCURVE*;

struct TTPOLYGONHEADER {
    DWORD cb;
    DWORD dwType;
    POINTFX pfxStart;
}
alias LPTTPOLYGONHEADER = TTPOLYGONHEADER*;

struct POINTFLOAT {
    FLOAT x;
    FLOAT y;
}
alias PPOINTFLOAT = POINTFLOAT*;

struct GLYPHMETRICSFLOAT {
    FLOAT gmfBlackBoxX;
    FLOAT gmfBlackBoxY;
    POINTFLOAT gmfptGlyphOrigin;
    FLOAT gmfCellIncX;
    FLOAT gmfCellIncY;
}
alias PGLYPHMETRICSFLOAT = GLYPHMETRICSFLOAT*, LPGLYPHMETRICSFLOAT = GLYPHMETRICSFLOAT*;

struct LAYERPLANEDESCRIPTOR {
    WORD nSize;
    WORD nVersion;
    DWORD dwFlags;
    BYTE iPixelType;
    BYTE cColorBits;
    BYTE cRedBits;
    BYTE cRedShift;
    BYTE cGreenBits;
    BYTE cGreenShift;
    BYTE cBlueBits;
    BYTE cBlueShift;
    BYTE cAlphaBits;
    BYTE cAlphaShift;
    BYTE cAccumBits;
    BYTE cAccumRedBits;
    BYTE cAccumGreenBits;
    BYTE cAccumBlueBits;
    BYTE cAccumAlphaBits;
    BYTE cDepthBits;
    BYTE cStencilBits;
    BYTE cAuxBuffers;
    BYTE iLayerPlane;
    BYTE bReserved;
    COLORREF crTransparent;
}
alias PLAYERPLANEDESCRIPTOR = LAYERPLANEDESCRIPTOR*, LPLAYERPLANEDESCRIPTOR = LAYERPLANEDESCRIPTOR*;

struct BLENDFUNCTION {
    BYTE BlendOp;
    BYTE BlendFlags;
    BYTE SourceConstantAlpha;
    BYTE AlphaFormat;
}
alias PBLENDFUNCTION = BLENDFUNCTION*, LPBLENDFUNCTION = BLENDFUNCTION*;

enum MM_MAX_NUMAXES = 16;

struct DESIGNVECTOR {
    DWORD dvReserved;
    DWORD dvNumAxes;
    LONG[MM_MAX_NUMAXES] dvValues;
}
alias PDESIGNVECTOR = DESIGNVECTOR*, LPDESIGNVECTOR = DESIGNVECTOR*;
enum STAMP_DESIGNVECTOR = 0x8000000 + 'd' + ('v' << 8);
enum STAMP_AXESLIST     = 0x8000000 + 'a' + ('l' << 8);

static if (_WIN32_WINNT >= 0x500) {

enum MM_MAX_AXES_NAMELEN = 16;

    struct AXISINFOA {
        LONG axMinValue;
        LONG axMaxValue;
        BYTE[MM_MAX_AXES_NAMELEN] axAxisName;
    }
    alias PAXISINFOA = AXISINFOA*, LPAXISINFOA = AXISINFOA*;

    struct AXISINFOW {
        LONG axMinValue;
        LONG axMaxValue;
        WCHAR[MM_MAX_AXES_NAMELEN] axAxisName = 0;
    }
    alias PAXISINFOW = AXISINFOW*, LPAXISINFOW = AXISINFOW*;

    version (Unicode) {
        alias AXISINFO = AXISINFOW;
        alias PAXISINFO = PAXISINFOW;
        alias LPAXISINFO = LPAXISINFOW;
    }
    else {
        alias AXISINFO = AXISINFOA;
        alias PAXISINFO = PAXISINFOA;
        alias LPAXISINFO = LPAXISINFOA;
    }

    struct AXESLISTA {
        DWORD axlReserved;
        DWORD axlNumAxes;
        AXISINFOA[MM_MAX_NUMAXES] axlAxisInfo;
    }
    alias PAXESLISTA = AXESLISTA*, LPAXESLISTA = AXESLISTA*;

    struct AXESLISTW {
        DWORD axlReserved;
        DWORD axlNumAxes;
        AXISINFOW[MM_MAX_NUMAXES] axlAxisInfo;
    }
    alias PAXESLISTW = AXESLISTW*, LPAXESLISTW = AXESLISTW*;

    version (Unicode) {
        alias AXESLIST = AXESLISTW;
        alias PAXESLIST = PAXESLISTW;
        alias LPAXESLIST = LPAXESLISTW;
    }
    else {
        alias AXESLIST = AXESLISTA;
        alias PAXESLIST = PAXESLISTA;
        alias LPAXESLIST = LPAXESLISTA;
    }

    struct ENUMLOGFONTEXDVA {
        ENUMLOGFONTEXA elfEnumLogfontEx;
        DESIGNVECTOR   elfDesignVector;
    }
    alias PENUMLOGFONTEXDVA = ENUMLOGFONTEXDVA*, LPENUMLOGFONTEXDVA = ENUMLOGFONTEXDVA*;

    struct ENUMLOGFONTEXDVW {
        ENUMLOGFONTEXW elfEnumLogfontEx;
        DESIGNVECTOR   elfDesignVector;
    }
    alias PENUMLOGFONTEXDVW = ENUMLOGFONTEXDVW*, LPENUMLOGFONTEXDVW = ENUMLOGFONTEXDVW*;

extern(Windows) nothrow @nogc {
    HFONT CreateFontIndirectExA(const(ENUMLOGFONTEXDVA)*);
    HFONT CreateFontIndirectExW(const(ENUMLOGFONTEXDVW)*);
}
    version (Unicode)
        alias CreateFontIndirectEx = CreateFontIndirectExW;
    else
        alias CreateFontIndirectEx = CreateFontIndirectExA;

    struct ENUMTEXTMETRICA {
        NEWTEXTMETRICEXA etmNewTextMetricEx;
        AXESLISTA etmAxesList;
    }
    alias PENUMTEXTMETRICA = ENUMTEXTMETRICA*, LPENUMTEXTMETRICA = ENUMTEXTMETRICA*;

    struct ENUMTEXTMETRICW {
        NEWTEXTMETRICEXW etmNewTextMetricEx;
        AXESLISTW etmAxesList;
    }
    alias PENUMTEXTMETRICW = ENUMTEXTMETRICW*, LPENUMTEXTMETRICW = ENUMTEXTMETRICW*;

    version (Unicode) {
        alias ENUMTEXTMETRIC = ENUMTEXTMETRICW;
        alias PENUMTEXTMETRIC = PENUMTEXTMETRICW;
        alias LPENUMTEXTMETRIC = LPENUMTEXTMETRICW;
    }
    else {
        alias ENUMTEXTMETRIC = ENUMTEXTMETRICA;
        alias PENUMTEXTMETRIC = PENUMTEXTMETRICA;
        alias LPENUMTEXTMETRIC = LPENUMTEXTMETRICA;
    }
} /* _WIN32_WINNT >= 0x500 */

struct GRADIENT_TRIANGLE {
    ULONG Vertex1;
    ULONG Vertex2;
    ULONG Vertex3;
}
alias PGRADIENT_TRIANGLE = GRADIENT_TRIANGLE*, LPGRADIENT_TRIANGLE = GRADIENT_TRIANGLE*;

struct GRADIENT_RECT {
    ULONG UpperLeft;
    ULONG LowerRight;
}
alias PGRADIENT_RECT = GRADIENT_RECT*, LPGRADIENT_RECT = GRADIENT_RECT*;

struct DISPLAY_DEVICEA {
    DWORD cb;
    CHAR[32] DeviceName = 0;
    CHAR[128] DeviceString = 0;
    DWORD StateFlags;
    CHAR[128] DeviceID = 0;
    CHAR[128] DeviceKey = 0;
}
alias PDISPLAY_DEVICEA = DISPLAY_DEVICEA*, LPDISPLAY_DEVICEA = DISPLAY_DEVICEA*;

struct DISPLAY_DEVICEW {
    DWORD cb;
    WCHAR[32] DeviceName = 0;
    WCHAR[128] DeviceString = 0;
    DWORD StateFlags;
    WCHAR[128] DeviceID = 0;
    WCHAR[128] DeviceKey = 0;
}
alias PDISPLAY_DEVICEW = DISPLAY_DEVICEW*, LPDISPLAY_DEVICEW = DISPLAY_DEVICEW*;

struct DRAWPATRECT {
    POINT ptPosition;
    POINT ptSize;
    WORD wStyle;
    WORD wPattern;
}
alias PDRAWPATRECT = DRAWPATRECT*;

// ---------
// Callbacks
extern (Windows) {
    alias ABORTPROC = BOOL function (HDC, int);
    alias MFENUMPROC = int function (HDC, HANDLETABLE*, METARECORD*, int, LPARAM);
    alias ENHMFENUMPROC = int function (HDC, HANDLETABLE*, const(ENHMETARECORD)*, int, LPARAM);
    alias FONTENUMPROCA = int function (const(LOGFONTA)*, const(TEXTMETRICA)*, DWORD, LPARAM), OLDFONTENUMPROCA = int function (const(LOGFONTA)*, const(TEXTMETRICA)*, DWORD, LPARAM);
    alias FONTENUMPROCW = int function (const(LOGFONTW)*, const(TEXTMETRICW)*, DWORD, LPARAM), OLDFONTENUMPROCW = int function (const(LOGFONTW)*, const(TEXTMETRICW)*, DWORD, LPARAM);
    alias ICMENUMPROCA = int function (LPSTR, LPARAM);
    alias ICMENUMPROCW = int function (LPWSTR, LPARAM);
    alias GOBJENUMPROC = void function (LPVOID, LPARAM);
    alias LINEDDAPROC = void function (int, int, LPARAM);
    alias LPFNDEVMODE = UINT function (HWND, HMODULE, LPDEVMODEA, LPSTR, LPSTR, LPDEVMODEA, LPSTR, UINT);
    alias LPFNDEVCAPS = DWORD function (LPSTR, LPSTR, UINT, LPSTR, LPDEVMODEA);
}

// ---------
// C Macros.
// FIXME:
//POINTS MAKEPOINTS(DWORD dwValue) #define MAKEPOINTS(l) (*((POINTS*)&(l)))

nothrow @nogc {
    DWORD MAKEROP4(DWORD fore, DWORD back) {
        return ((back<<8) & 0xFF000000) | (fore);
    }

    COLORREF CMYK(BYTE c, BYTE m, BYTE y, BYTE k) {
        return cast(COLORREF)(k | (y << 8) | (m << 16) | (c << 24));
    }

    BYTE GetCValue(COLORREF cmyk) {
        return cast(BYTE)(cmyk >> 24);
    }

    BYTE GetMValue(COLORREF cmyk) {
        return cast(BYTE)(cmyk >> 16);
    }

    BYTE GetYValue(COLORREF cmyk) {
        return cast(BYTE)(cmyk >> 8);
    }

    BYTE GetKValue(COLORREF cmyk) {
        return cast(BYTE)cmyk;
    }

    COLORREF RGB(/*BYTE*/uint r, /*BYTE*/uint g, /*BYTE*/uint b) {
        return cast(COLORREF)(r | (g << 8) | (b << 16));
    }

    BYTE GetRValue(COLORREF c) {
        return cast(BYTE)c;
    }

    BYTE GetGValue(COLORREF c) {
        return cast(BYTE)(c >> 8);
    }

    BYTE GetBValue(COLORREF c) {
        return cast(BYTE)(c >> 16);
    }

    COLORREF PALETTEINDEX(WORD i) {
        return 0x01000000 | cast(COLORREF) i;
    }

    COLORREF PALETTERGB(BYTE r, BYTE g, BYTE b) {
        return 0x02000000|RGB(r, g, b);
    }
}

extern(Windows) nothrow @nogc {
    int AbortDoc(HDC);
    BOOL AbortPath(HDC);
    int AddFontResourceA(LPCSTR);
    int AddFontResourceW(LPCWSTR);
    BOOL AngleArc(HDC, int, int, DWORD, FLOAT, FLOAT);
    BOOL AnimatePalette(HPALETTE, UINT, UINT, const(PALETTEENTRY)*);
    BOOL Arc(HDC, int, int, int, int, int, int, int, int);
    BOOL ArcTo(HDC, int, int, int, int, int, int, int, int);
    BOOL BeginPath(HDC);
    BOOL BitBlt(HDC, int, int, int, int, HDC, int, int, DWORD);
    BOOL CancelDC(HDC);
    BOOL CheckColorsInGamut(HDC, PVOID, PVOID, DWORD);
    BOOL Chord(HDC, int, int, int, int, int, int, int, int);
    int ChoosePixelFormat(HDC, const(PIXELFORMATDESCRIPTOR)*);
    HENHMETAFILE CloseEnhMetaFile(HDC);
    BOOL CloseFigure(HDC);
    HMETAFILE CloseMetaFile(HDC);
    BOOL ColorMatchToTarget(HDC, HDC, DWORD);
    BOOL ColorCorrectPalette(HDC, HPALETTE, DWORD, DWORD);
    int CombineRgn(HRGN, HRGN, HRGN, int);
    BOOL CombineTransform(LPXFORM, const(XFORM)*, const(XFORM)*);
    HENHMETAFILE CopyEnhMetaFileA(HENHMETAFILE, LPCSTR);
    HENHMETAFILE CopyEnhMetaFileW(HENHMETAFILE, LPCWSTR);
    HMETAFILE CopyMetaFileA(HMETAFILE, LPCSTR);
    HMETAFILE CopyMetaFileW(HMETAFILE, LPCWSTR);
    HBITMAP CreateBitmap(int, int, UINT, UINT, PCVOID);
    HBITMAP CreateBitmapIndirect(const(BITMAP)*);
    HBRUSH CreateBrushIndirect(const(LOGBRUSH)*);
    HCOLORSPACE CreateColorSpaceA(LPLOGCOLORSPACEA);
    HCOLORSPACE CreateColorSpaceW(LPLOGCOLORSPACEW);
    HBITMAP CreateCompatibleBitmap(HDC, int, int);
    HDC CreateCompatibleDC(HDC);
    HDC CreateDCA(LPCSTR, LPCSTR, LPCSTR, const(DEVMODEA)*);
    HDC CreateDCW(LPCWSTR, LPCWSTR, LPCWSTR, const(DEVMODEW)*);
    HBITMAP CreateDIBitmap(HDC, const(BITMAPINFOHEADER)*, DWORD, PCVOID, const(BITMAPINFO)*, UINT);
    HBRUSH CreateDIBPatternBrush(HGLOBAL, UINT);
    HBRUSH CreateDIBPatternBrushPt(PCVOID, UINT);
    HBITMAP CreateDIBSection(HDC, const(BITMAPINFO)*, UINT, void**, HANDLE, DWORD);
    HBITMAP CreateDiscardableBitmap(HDC, int, int);
    HRGN CreateEllipticRgn(int, int, int, int);
    HRGN CreateEllipticRgnIndirect(LPCRECT);
    HDC CreateEnhMetaFileA(HDC, LPCSTR, LPCRECT, LPCSTR);
    HDC CreateEnhMetaFileW(HDC, LPCWSTR, LPCRECT, LPCWSTR);
    HFONT CreateFontA(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCSTR);
    HFONT CreateFontW(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCWSTR);
    HFONT CreateFontIndirectA(const(LOGFONTA)*);
    HFONT CreateFontIndirectW(const(LOGFONTW)*);
    HPALETTE CreateHalftonePalette(HDC);
    HBRUSH CreateHatchBrush(int, COLORREF);
    HDC CreateICA(LPCSTR, LPCSTR, LPCSTR, const(DEVMODEA)*);
    HDC CreateICW(LPCWSTR, LPCWSTR, LPCWSTR, const(DEVMODEW)*);
    HDC CreateMetaFileA(LPCSTR);
    HDC CreateMetaFileW(LPCWSTR);
    HPALETTE CreatePalette(const(LOGPALETTE)*);
    HBRUSH CreatePatternBrush(HBITMAP);
    HPEN CreatePen(int, int, COLORREF);
    HPEN CreatePenIndirect(const(LOGPEN)*);
    HRGN CreatePolygonRgn(const(POINT)*, int, int);
    HRGN CreatePolyPolygonRgn(const(POINT)*, const(INT)*, int, int);
    HRGN CreateRectRgn(int, int, int, int);
    HRGN CreateRectRgnIndirect(LPCRECT);
    HRGN CreateRoundRectRgn(int, int, int, int, int, int);
    BOOL CreateScalableFontResourceA(DWORD, LPCSTR, LPCSTR, LPCSTR);
    BOOL CreateScalableFontResourceW(DWORD, LPCWSTR, LPCWSTR, LPCWSTR);
    HBRUSH CreateSolidBrush(COLORREF);
    BOOL DeleteColorSpace(HCOLORSPACE);
    BOOL DeleteDC(HDC);
    BOOL DeleteEnhMetaFile(HENHMETAFILE);
    BOOL DeleteMetaFile(HMETAFILE);
    BOOL DeleteObject(HGDIOBJ);
    int DescribePixelFormat(HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
    DWORD DeviceCapabilitiesA(LPCSTR, LPCSTR, WORD, LPSTR, const(DEVMODEA)*);
    DWORD DeviceCapabilitiesW(LPCWSTR, LPCWSTR, WORD, LPWSTR, const(DEVMODEW)*);
    BOOL DPtoLP(HDC, LPPOINT, int);
    int DrawEscape(HDC, int, int, LPCSTR);
    BOOL Ellipse(HDC, int, int, int, int);
    int EndDoc(HDC);
    int EndPage(HDC);
    BOOL EndPath(HDC);
    BOOL EnumEnhMetaFile(HDC, HENHMETAFILE, ENHMFENUMPROC, PVOID, LPCRECT);
    int EnumFontFamiliesA(HDC, LPCSTR, FONTENUMPROCA, LPARAM);
    int EnumFontFamiliesW(HDC, LPCWSTR, FONTENUMPROCW, LPARAM);
    int EnumFontFamiliesExA(HDC, PLOGFONTA, FONTENUMPROCA, LPARAM, DWORD);
    int EnumFontFamiliesExW(HDC, PLOGFONTW, FONTENUMPROCW, LPARAM, DWORD);
    int EnumFontsA(HDC, LPCSTR, FONTENUMPROCA, LPARAM);
    int EnumFontsW(HDC, LPCWSTR, FONTENUMPROCW, LPARAM);
    int EnumICMProfilesA(HDC, ICMENUMPROCA, LPARAM);
    int EnumICMProfilesW(HDC, ICMENUMPROCW, LPARAM);
    BOOL EnumMetaFile(HDC, HMETAFILE, MFENUMPROC, LPARAM);
    int EnumObjects(HDC, int, GOBJENUMPROC, LPARAM);
    BOOL EqualRgn(HRGN, HRGN);
    int Escape(HDC, int, int, LPCSTR, PVOID);
    int ExcludeClipRect(HDC, int, int, int, int);
    int ExcludeUpdateRgn(HDC, HWND);
    HPEN ExtCreatePen(DWORD, DWORD, const(LOGBRUSH)*, DWORD, const(DWORD)*);
    HRGN ExtCreateRegion(const(XFORM)*, DWORD, const(RGNDATA)*);
    int ExtEscape(HDC, int, int, LPCSTR, int, LPSTR);
    BOOL ExtFloodFill(HDC, int, int, COLORREF, UINT);
    int ExtSelectClipRgn(HDC, HRGN, int);
    BOOL ExtTextOutA(HDC, int, int, UINT, LPCRECT, LPCSTR, UINT, const(INT)*);
    BOOL ExtTextOutW(HDC, int, int, UINT, LPCRECT, LPCWSTR, UINT, const(INT)*);
    BOOL FillPath(HDC);
    int FillRect(HDC, LPCRECT, HBRUSH);
    int FillRgn(HDC, HRGN, HBRUSH);
    BOOL FixBrushOrgEx(HDC, int, int, LPPOINT);
    BOOL FlattenPath(HDC);
    BOOL FloodFill(HDC, int, int, COLORREF);
    BOOL FrameRgn(HDC, HRGN, HBRUSH, int, int);
    BOOL GdiComment(HDC, UINT, const(BYTE)*);
    BOOL GdiFlush();
    DWORD GdiGetBatchLimit();
    DWORD GdiSetBatchLimit(DWORD);
    int GetArcDirection(HDC);
    BOOL GetAspectRatioFilterEx(HDC, LPSIZE);
    LONG GetBitmapBits(HBITMAP, LONG, PVOID);
    BOOL GetBitmapDimensionEx(HBITMAP, LPSIZE);
    COLORREF GetBkColor(HDC);
    int GetBkMode(HDC);
    UINT GetBoundsRect(HDC, LPRECT, UINT);
    BOOL GetBrushOrgEx(HDC, LPPOINT);
    BOOL GetCharABCWidthsA(HDC, UINT, UINT, LPABC);
    BOOL GetCharABCWidthsW(HDC, UINT, UINT, LPABC);
    BOOL GetCharABCWidthsFloatA(HDC, UINT, UINT, LPABCFLOAT);
    BOOL GetCharABCWidthsFloatW(HDC, UINT, UINT, LPABCFLOAT);
    DWORD GetCharacterPlacementA(HDC, LPCSTR, int, int, LPGCP_RESULTSA, DWORD);
    DWORD GetCharacterPlacementW(HDC, LPCWSTR, int, int, LPGCP_RESULTSW, DWORD);
    BOOL GetCharWidth32A(HDC, UINT, UINT, LPINT);
    BOOL GetCharWidth32W(HDC, UINT, UINT, LPINT);
    BOOL GetCharWidthA(HDC, UINT, UINT, LPINT);
    BOOL GetCharWidthW(HDC, UINT, UINT, LPINT);
    BOOL GetCharWidthFloatA(HDC, UINT, UINT, PFLOAT);
    BOOL GetCharWidthFloatW(HDC, UINT, UINT, PFLOAT);
    int GetClipBox(HDC, LPRECT);
    int GetClipRgn(HDC, HRGN);
    BOOL GetColorAdjustment(HDC, LPCOLORADJUSTMENT);
    HANDLE GetColorSpace(HDC);
    HGDIOBJ GetCurrentObject(HDC, UINT);
    BOOL GetCurrentPositionEx(HDC, LPPOINT);
    HCURSOR GetCursor();
    BOOL GetDCOrgEx(HDC, LPPOINT);
    static if (_WIN32_WINNT >= 0x500)
    {
        DWORD GetDCPenColor(HGDIOBJ);
        COLORREF GetDCBrushColor(HGDIOBJ);
    }
    int GetDeviceCaps(HDC, int);
    BOOL GetDeviceGammaRamp(HDC, PVOID);
    UINT GetDIBColorTable(HDC, UINT, UINT, RGBQUAD*);
    int GetDIBits(HDC, HBITMAP, UINT, UINT, PVOID, LPBITMAPINFO, UINT);
    HENHMETAFILE GetEnhMetaFileA(LPCSTR);
    HENHMETAFILE GetEnhMetaFileW(LPCWSTR);
    UINT GetEnhMetaFileBits(HENHMETAFILE, UINT, LPBYTE);
    UINT GetEnhMetaFileDescriptionA(HENHMETAFILE, UINT, LPSTR);
    UINT GetEnhMetaFileDescriptionW(HENHMETAFILE, UINT, LPWSTR);
    UINT GetEnhMetaFileHeader(HENHMETAFILE, UINT, LPENHMETAHEADER);
    UINT GetEnhMetaFilePaletteEntries(HENHMETAFILE, UINT, LPPALETTEENTRY);
    UINT GetEnhMetaFilePixelFormat(HENHMETAFILE, DWORD, const(PIXELFORMATDESCRIPTOR)*);
    DWORD GetFontData(HDC, DWORD, DWORD, PVOID, DWORD);
    DWORD GetFontLanguageInfo(HDC);
    DWORD GetGlyphOutlineA(HDC, UINT, UINT, LPGLYPHMETRICS, DWORD, PVOID, const(MAT2)*);
    DWORD GetGlyphOutlineW(HDC, UINT, UINT, LPGLYPHMETRICS, DWORD, PVOID, const(MAT2)*);
    int GetGraphicsMode(HDC);
    BOOL GetICMProfileA(HDC, LPDWORD, LPSTR);
    BOOL GetICMProfileW(HDC, LPDWORD, LPWSTR);
    DWORD GetKerningPairsA(HDC, DWORD, LPKERNINGPAIR);
    DWORD GetKerningPairsW(HDC, DWORD, LPKERNINGPAIR);
    BOOL GetLogColorSpaceA(HCOLORSPACE, LPLOGCOLORSPACEA, DWORD);
    BOOL GetLogColorSpaceW(HCOLORSPACE, LPLOGCOLORSPACEW, DWORD);
    int GetMapMode(HDC);
    HMETAFILE GetMetaFileA(LPCSTR);
    HMETAFILE GetMetaFileW(LPCWSTR);
    UINT GetMetaFileBitsEx(HMETAFILE, UINT, PVOID);
    int GetMetaRgn(HDC, HRGN);
    BOOL GetMiterLimit(HDC, PFLOAT);
    COLORREF GetNearestColor(HDC, COLORREF);
    UINT GetNearestPaletteIndex(HPALETTE, COLORREF);
    int GetObjectA(HGDIOBJ, int, PVOID);
    int GetObjectW(HGDIOBJ, int, PVOID);
    DWORD GetObjectType(HGDIOBJ);
    UINT GetOutlineTextMetricsA(HDC, UINT, LPOUTLINETEXTMETRICA);
    UINT GetOutlineTextMetricsW(HDC, UINT, LPOUTLINETEXTMETRICW);
    UINT GetPaletteEntries(HPALETTE, UINT, UINT, LPPALETTEENTRY);
    int GetPath(HDC, LPPOINT, PBYTE, int);
    COLORREF GetPixel(HDC, int, int);
    int GetPixelFormat(HDC);
    int GetPolyFillMode(HDC);
    BOOL GetRasterizerCaps(LPRASTERIZER_STATUS, UINT);
    int GetRandomRgn (HDC, HRGN, INT);
    DWORD GetRegionData(HRGN, DWORD, LPRGNDATA);
    int GetRgnBox(HRGN, LPRECT);
    int GetROP2(HDC);
    HGDIOBJ GetStockObject(int);
    int GetStretchBltMode(HDC);
    UINT GetSystemPaletteEntries(HDC, UINT, UINT, LPPALETTEENTRY);
    UINT GetSystemPaletteUse(HDC);
    UINT GetTextAlign(HDC);
    int GetTextCharacterExtra(HDC);
    int GetTextCharset(HDC);
    int GetTextCharsetInfo(HDC, LPFONTSIGNATURE, DWORD);
    COLORREF GetTextColor(HDC);
    BOOL GetTextExtentExPointA(HDC, LPCSTR, int, int, LPINT, LPINT, LPSIZE);
    BOOL GetTextExtentExPointW(HDC, LPCWSTR, int, int, LPINT, LPINT, LPSIZE);
    BOOL GetTextExtentPointA(HDC, LPCSTR, int, LPSIZE);
    BOOL GetTextExtentPointW(HDC, LPCWSTR, int, LPSIZE);
    BOOL GetTextExtentPoint32A(HDC, LPCSTR, int, LPSIZE);
    BOOL GetTextExtentPoint32W(HDC, LPCWSTR, int, LPSIZE);
    int GetTextFaceA(HDC, int, LPSTR);
    int GetTextFaceW(HDC, int, LPWSTR);
    BOOL GetTextMetricsA(HDC, LPTEXTMETRICA);
    BOOL GetTextMetricsW(HDC, LPTEXTMETRICW);
    BOOL GetViewportExtEx(HDC, LPSIZE);
    BOOL GetViewportOrgEx(HDC, LPPOINT);
    BOOL GetWindowExtEx(HDC, LPSIZE);
    BOOL GetWindowOrgEx(HDC, LPPOINT);
    UINT GetWinMetaFileBits(HENHMETAFILE, UINT, LPBYTE, INT, HDC);
    BOOL GetWorldTransform(HDC, LPXFORM);
    int IntersectClipRect(HDC, int, int, int, int);
    BOOL InvertRgn(HDC, HRGN);
    BOOL LineDDA(int, int, int, int, LINEDDAPROC, LPARAM);
    BOOL LineTo(HDC, int, int);
    BOOL LPtoDP(HDC, LPPOINT, int);
    BOOL MaskBlt(HDC, int, int, int, int, HDC, int, int, HBITMAP, int, int, DWORD);
    BOOL ModifyWorldTransform(HDC, const(XFORM)*, DWORD);
    BOOL MoveToEx(HDC, int, int, LPPOINT);
    int OffsetClipRgn(HDC, int, int);
    int OffsetRgn(HRGN, int, int);
    BOOL OffsetViewportOrgEx(HDC, int, int, LPPOINT);
    BOOL OffsetWindowOrgEx(HDC, int, int, LPPOINT);
    BOOL PaintRgn(HDC, HRGN);
    BOOL PatBlt(HDC, int, int, int, int, DWORD);
    HRGN PathToRegion(HDC);
    BOOL Pie(HDC, int, int, int, int, int, int, int, int);
    BOOL PlayEnhMetaFile(HDC, HENHMETAFILE, LPCRECT);
    BOOL PlayEnhMetaFileRecord(HDC, LPHANDLETABLE, const(ENHMETARECORD)*, UINT);
    BOOL PlayMetaFile(HDC, HMETAFILE);
    BOOL PlayMetaFileRecord(HDC, LPHANDLETABLE, LPMETARECORD, UINT);
    BOOL PlgBlt(HDC, const(POINT)*, HDC, int, int, int, int, HBITMAP, int, int);
    BOOL PolyBezier(HDC, const(POINT)*, DWORD);
    BOOL PolyBezierTo(HDC, const(POINT)*, DWORD);
    BOOL PolyDraw(HDC, const(POINT)*, const(BYTE)*, int);
    BOOL Polygon(HDC, const(POINT)*, int);
    BOOL Polyline(HDC, const(POINT)*, int);
    BOOL PolylineTo(HDC, const(POINT)*, DWORD);
    BOOL PolyPolygon(HDC, const(POINT)*, const(INT)*, int);
    BOOL PolyPolyline(HDC, const(POINT)*, const(DWORD)*, DWORD);
    BOOL PolyTextOutA(HDC, const(POLYTEXTA)*, int);
    BOOL PolyTextOutW(HDC, const(POLYTEXTW)*, int);
    BOOL PtInRegion(HRGN, int, int);
    BOOL PtVisible(HDC, int, int);
    UINT RealizePalette(HDC);
    BOOL Rectangle(HDC, int, int, int, int);
    BOOL RectInRegion(HRGN, LPCRECT);
    BOOL RectVisible(HDC, LPCRECT);
    BOOL RemoveFontResourceA(LPCSTR);
    BOOL RemoveFontResourceW(LPCWSTR);

    HDC ResetDCA(HDC, const(DEVMODEA)*);
    HDC ResetDCW(HDC, const(DEVMODEW)*);
    BOOL ResizePalette(HPALETTE, UINT);
    BOOL RestoreDC(HDC, int);
    BOOL RoundRect(HDC, int, int, int, int, int, int);
    int SaveDC(HDC);
    BOOL ScaleViewportExtEx(HDC, int, int, int, int, LPSIZE);
    BOOL ScaleWindowExtEx(HDC, int, int, int, int, LPSIZE);
    BOOL SelectClipPath(HDC, int);
    int SelectClipRgn(HDC, HRGN);
    HGDIOBJ SelectObject(HDC, HGDIOBJ);
    HPALETTE SelectPalette(HDC, HPALETTE, BOOL);
    int SetAbortProc(HDC, ABORTPROC);
    int SetArcDirection(HDC, int);
    LONG SetBitmapBits(HBITMAP, DWORD, PCVOID);
    BOOL SetBitmapDimensionEx(HBITMAP, int, int, LPSIZE);
    COLORREF SetBkColor(HDC, COLORREF);
    int SetBkMode(HDC, int);
    UINT SetBoundsRect(HDC, LPCRECT, UINT);
    BOOL SetBrushOrgEx(HDC, int, int, LPPOINT);
    BOOL SetColorAdjustment(HDC, const(COLORADJUSTMENT)*);
    BOOL SetColorSpace(HDC, HCOLORSPACE);

    BOOL SetDeviceGammaRamp(HDC, PVOID);
    UINT SetDIBColorTable(HDC, UINT, UINT, const(RGBQUAD)*);
    int SetDIBits(HDC, HBITMAP, UINT, UINT, PCVOID, const(BITMAPINFO)*, UINT);
    int SetDIBitsToDevice(HDC, int, int, DWORD, DWORD, int, int, UINT, UINT, PCVOID, const(BITMAPINFO)*, UINT);
    HENHMETAFILE SetEnhMetaFileBits(UINT, const(BYTE)*);
    int SetGraphicsMode(HDC, int);
    int SetICMMode(HDC, int);
    BOOL SetICMProfileA(HDC, LPSTR);
    BOOL SetICMProfileW(HDC, LPWSTR);
    int SetMapMode(HDC, int);

    static if (_WIN32_WINNT >= 0x500) {
        DWORD SetLayout(HDC hdc, DWORD l);
        DWORD GetLayout(HDC hdc);
    }

    DWORD SetMapperFlags(HDC, DWORD);
    HMETAFILE SetMetaFileBitsEx(UINT, const(BYTE)*);
    int SetMetaRgn(HDC);
    BOOL SetMiterLimit(HDC, FLOAT, PFLOAT);
    UINT SetPaletteEntries(HPALETTE, UINT, UINT, const(PALETTEENTRY)*);
    COLORREF SetPixel(HDC, int, int, COLORREF);
    BOOL SetPixelFormat(HDC, int, const(PIXELFORMATDESCRIPTOR)*);
    BOOL SetPixelV(HDC, int, int, COLORREF);
    int SetPolyFillMode(HDC, int);
    BOOL SetRectRgn(HRGN, int, int, int, int);
    int SetROP2(HDC, int);
    int SetStretchBltMode(HDC, int);
    UINT SetSystemPaletteUse(HDC, UINT);
    UINT SetTextAlign(HDC, UINT);
    int SetTextCharacterExtra(HDC, int);
    COLORREF SetTextColor(HDC, COLORREF);
    BOOL SetTextJustification(HDC, int, int);
    BOOL SetViewportExtEx(HDC, int, int, LPSIZE);
    BOOL SetViewportOrgEx(HDC, int, int, LPPOINT);
    BOOL SetWindowExtEx(HDC, int, int, LPSIZE);
    BOOL SetWindowOrgEx(HDC, int, int, LPPOINT);
    HENHMETAFILE SetWinMetaFileBits(UINT, const(BYTE)*, HDC, const(METAFILEPICT)*);
    BOOL SetWorldTransform(HDC, const(XFORM)*);
    int StartDocA(HDC, const(DOCINFOA)*);
    int StartDocW(HDC, const(DOCINFOW)*);
    int StartPage(HDC);
    BOOL StretchBlt(HDC, int, int, int, int, HDC, int, int, int, int, DWORD);
    int StretchDIBits(HDC, int, int, int, int, int, int, int, int, const(VOID)* , const(BITMAPINFO)* , UINT, DWORD);
    BOOL StrokeAndFillPath(HDC);
    BOOL StrokePath(HDC);
    BOOL SwapBuffers(HDC);
    BOOL TextOutA(HDC, int, int, LPCSTR, int);
    BOOL TextOutW(HDC, int, int, LPCWSTR, int);
    BOOL TranslateCharsetInfo(PDWORD, LPCHARSETINFO, DWORD);
    BOOL UnrealizeObject(HGDIOBJ);
    BOOL UpdateColors(HDC);
    BOOL UpdateICMRegKeyA(DWORD, DWORD, LPSTR, UINT);
    BOOL UpdateICMRegKeyW(DWORD, DWORD, LPWSTR, UINT);
    BOOL WidenPath(HDC);
    BOOL wglCopyContext(HGLRC, HGLRC, UINT);
    HGLRC wglCreateContext(HDC);
    HGLRC wglCreateLayerContext(HDC, int);
    BOOL wglDeleteContext(HGLRC);
    BOOL wglDescribeLayerPlane(HDC, int, int, UINT, LPLAYERPLANEDESCRIPTOR);
    HGLRC wglGetCurrentContext();
    HDC wglGetCurrentDC();
    int wglGetLayerPaletteEntries(HDC, int, int, int, COLORREF*);
    PROC wglGetProcAddress(LPCSTR);
    BOOL wglMakeCurrent(HDC, HGLRC);
    BOOL wglRealizeLayerPalette(HDC, int, BOOL);
    int wglSetLayerPaletteEntries(HDC, int, int, int, const(COLORREF)*);
    BOOL wglShareLists(HGLRC, HGLRC);
    BOOL wglSwapLayerBuffers(HDC, UINT);
    BOOL wglUseFontBitmapsA(HDC, DWORD, DWORD, DWORD);
    BOOL wglUseFontBitmapsW(HDC, DWORD, DWORD, DWORD);
    BOOL wglUseFontOutlinesA(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT);
    BOOL wglUseFontOutlinesW(HDC, DWORD, DWORD, DWORD, FLOAT, FLOAT, int, LPGLYPHMETRICSFLOAT);

    static if (_WIN32_WINNT >= 0x500) {
    alias PWGLSWAP = WGLSWAP*;
    struct WGLSWAP {
        HDC hdc;
        UINT uiFlags;
    }
enum WGL_SWAPMULTIPLE_MAX = 16;
    DWORD  wglSwapMultipleBuffers(UINT, WGLSWAP*);
}

static if (_WIN32_WINNT >= 0x500) {
        BOOL AlphaBlend(HDC, int, int, int, int, HDC, int, int, int, int, BLENDFUNCTION);
        BOOL GradientFill(HDC, PTRIVERTEX, ULONG, PVOID, ULONG, ULONG);
        BOOL TransparentBlt(HDC, int, int, int, int, HDC, int, int, int, int, UINT);
    }

    static if (_WIN32_WINNT >= 0x500) {
        COLORREF SetDCBrushColor(HDC, COLORREF);
        COLORREF SetDCPenColor(HDC, COLORREF);
        HANDLE AddFontMemResourceEx(PVOID, DWORD, PVOID, DWORD*);
        int AddFontResourceExA(LPCSTR, DWORD, PVOID);
        int AddFontResourceExW(LPCWSTR, DWORD, PVOID);
        BOOL RemoveFontMemResourceEx(HANDLE);
        BOOL RemoveFontResourceExA(LPCSTR, DWORD, PVOID);
        BOOL RemoveFontResourceExW(LPCWSTR, DWORD, PVOID);
        DWORD GetFontUnicodeRanges(HDC, LPGLYPHSET);
        DWORD GetGlyphIndicesA(HDC, LPCSTR, int, LPWORD, DWORD);
        DWORD GetGlyphIndicesW(HDC, LPCWSTR, int, LPWORD, DWORD);
        BOOL GetTextExtentPointI(HDC, LPWORD, int, LPSIZE);
        BOOL GetTextExtentExPointI(HDC, LPWORD, int, int, LPINT, LPINT, LPSIZE);
        BOOL GetCharWidthI(HDC, UINT, UINT, LPWORD, LPINT);
        BOOL GetCharABCWidthsI(HDC, UINT, UINT, LPWORD, LPABC);
    }
} // extern (Windows)

version (Unicode) {
    alias BCHAR = WCHAR;
    alias DOCINFO = DOCINFOW;
    alias LOGFONT = LOGFONTW;

    alias TEXTMETRIC = TEXTMETRICW;
    alias NPTEXTMETRIC = NPTEXTMETRICW;
    alias ICMENUMPROC = ICMENUMPROCW;
    alias FONTENUMPROC = FONTENUMPROCW;
    alias DEVMODE = DEVMODEW;

    alias EXTLOGFONT = EXTLOGFONTW;
    alias GCP_RESULTS = GCP_RESULTSW;
    alias OUTLINETEXTMETRIC = OUTLINETEXTMETRICW;
    alias POLYTEXT = POLYTEXTW;
    alias LOGCOLORSPACE = LOGCOLORSPACEW;
    alias NEWTEXTMETRIC = NEWTEXTMETRICW;
    alias NEWTEXTMETRICEX = NEWTEXTMETRICEXW;
    alias ENUMLOGFONT = ENUMLOGFONTW;
    alias ENUMLOGFONTEX = ENUMLOGFONTEXW;
    alias DISPLAY_DEVICE = DISPLAY_DEVICEW;
    alias AddFontResource = AddFontResourceW;

    alias CopyEnhMetaFile = CopyEnhMetaFileW;
    alias CopyMetaFile = CopyMetaFileW;
    alias CreateColorSpace = CreateColorSpaceW;
    alias CreateDC = CreateDCW;
    alias CreateEnhMetaFile = CreateEnhMetaFileW;
    alias CreateFont = CreateFontW;
    alias CreateFontIndirect = CreateFontIndirectW;
    alias CreateIC = CreateICW;
    alias CreateMetaFile = CreateMetaFileW;
    alias CreateScalableFontResource = CreateScalableFontResourceW;
    alias DeviceCapabilities = DeviceCapabilitiesW;
    alias EnumFontFamilies = EnumFontFamiliesW;
    alias EnumFontFamiliesEx = EnumFontFamiliesExW;
    alias EnumFonts = EnumFontsW;
    alias EnumICMProfiles = EnumICMProfilesW;
    alias ExtTextOut = ExtTextOutW;
    alias GetCharABCWidthsFloat = GetCharABCWidthsFloatW;
    alias GetCharABCWidths = GetCharABCWidthsW;
    alias GetCharacterPlacement = GetCharacterPlacementW;
    alias GetCharWidth32 = GetCharWidth32W;
    alias GetCharWidthFloat = GetCharWidthFloatW;
    alias GetCharWidth = GetCharWidthW;
    alias GetEnhMetaFile = GetEnhMetaFileW;
    alias GetEnhMetaFileDescription = GetEnhMetaFileDescriptionW;
    alias GetGlyphOutline = GetGlyphOutlineW;
    alias GetICMProfile = GetICMProfileW;
    alias GetKerningPairs = GetKerningPairsW;
    alias GetLogColorSpace = GetLogColorSpaceW;
    alias GetMetaFile = GetMetaFileW;
    alias GetObject = GetObjectW;
    alias GetOutlineTextMetrics = GetOutlineTextMetricsW;
    alias GetTextExtentPoint = GetTextExtentPointW;
    alias GetTextExtentExPoint = GetTextExtentExPointW;
    alias GetTextExtentPoint32 = GetTextExtentPoint32W;
    alias GetTextFace = GetTextFaceW;
    alias GetTextMetrics = GetTextMetricsW;
    alias PolyTextOut = PolyTextOutW;
    alias RemoveFontResource = RemoveFontResourceW;

    alias ResetDC = ResetDCW;
    alias SetICMProfile = SetICMProfileW;
    alias StartDoc = StartDocW;
    alias TextOut = TextOutW;
    alias UpdateICMRegKey = UpdateICMRegKeyW;
    alias wglUseFontBitmaps = wglUseFontBitmapsW;
    alias wglUseFontOutlines = wglUseFontOutlinesW;
    static if (_WIN32_WINNT >= 0x500) {
        alias ENUMLOGFONTEXDV = ENUMLOGFONTEXDVW;
        alias PENUMLOGFONTEXDV = PENUMLOGFONTEXDVW;
        alias LPENUMLOGFONTEXDV = LPENUMLOGFONTEXDVW;
        alias AddFontResourceEx = AddFontResourceExW;
        alias RemoveFontResourceEx = RemoveFontResourceExW;
        alias GetGlyphIndices = GetGlyphIndicesW;
    }
} else { /* non-unicode build */
    alias BCHAR = BYTE;
    alias DOCINFO = DOCINFOA;
    alias LOGFONT = LOGFONTA;
    alias TEXTMETRIC = TEXTMETRICA;
    alias NPTEXTMETRIC = NPTEXTMETRICA;
    alias ICMENUMPROC = ICMENUMPROCA;
    alias FONTENUMPROC = FONTENUMPROCA;
    alias DEVMODE = DEVMODEA;
    alias EXTLOGFONT = EXTLOGFONTA;
    alias GCP_RESULTS = GCP_RESULTSA;
    alias OUTLINETEXTMETRIC = OUTLINETEXTMETRICA;
    alias POLYTEXT = POLYTEXTA;
    alias LOGCOLORSPACE = LOGCOLORSPACEA;
    alias NEWTEXTMETRIC = NEWTEXTMETRICA;
    alias NEWTEXTMETRICEX = NEWTEXTMETRICEXA;
    alias ENUMLOGFONT = ENUMLOGFONTA;
    alias ENUMLOGFONTEX = ENUMLOGFONTEXA;
    alias DISPLAY_DEVICE = DISPLAY_DEVICEA;

    alias AddFontResource = AddFontResourceA;
    alias CopyEnhMetaFile = CopyEnhMetaFileA;
    alias CopyMetaFile = CopyMetaFileA;
    alias CreateColorSpace = CreateColorSpaceA;
    alias CreateDC = CreateDCA;
    alias CreateEnhMetaFile = CreateEnhMetaFileA;
    alias CreateFont = CreateFontA;
    alias CreateFontIndirect = CreateFontIndirectA;
    alias CreateIC = CreateICA;
    alias CreateMetaFile = CreateMetaFileA;
    alias CreateScalableFontResource = CreateScalableFontResourceA;
    alias DeviceCapabilities = DeviceCapabilitiesA;
    alias EnumFontFamilies = EnumFontFamiliesA;
    alias EnumFontFamiliesEx = EnumFontFamiliesExA;
    alias EnumFonts = EnumFontsA;
    alias EnumICMProfiles = EnumICMProfilesA;
    alias ExtTextOut = ExtTextOutA;
    alias GetCharWidthFloat = GetCharWidthFloatA;
    alias GetCharWidth = GetCharWidthA;
    alias GetCharacterPlacement = GetCharacterPlacementA;
    alias GetCharABCWidths = GetCharABCWidthsA;
    alias GetCharABCWidthsFloat = GetCharABCWidthsFloatA;
    alias GetCharWidth32 = GetCharWidth32A;
    alias GetEnhMetaFile = GetEnhMetaFileA;
    alias GetEnhMetaFileDescription = GetEnhMetaFileDescriptionA;
    alias GetGlyphOutline = GetGlyphOutlineA;
    alias GetICMProfile = GetICMProfileA;
    alias GetKerningPairs = GetKerningPairsA;
    alias GetLogColorSpace = GetLogColorSpaceA;
    alias GetMetaFile = GetMetaFileA;
    alias GetObject = GetObjectA;
    alias GetOutlineTextMetrics = GetOutlineTextMetricsA;
    alias GetTextExtentPoint = GetTextExtentPointA;
    alias GetTextExtentExPoint = GetTextExtentExPointA;
    alias GetTextExtentPoint32 = GetTextExtentPoint32A;
    alias GetTextFace = GetTextFaceA;
    alias GetTextMetrics = GetTextMetricsA;
    alias PolyTextOut = PolyTextOutA;
    alias RemoveFontResource = RemoveFontResourceA;
    alias ResetDC = ResetDCA;
    alias SetICMProfile = SetICMProfileA;
    alias StartDoc = StartDocA;
    alias TextOut = TextOutA;
    alias UpdateICMRegKey = UpdateICMRegKeyA;
    alias wglUseFontBitmaps = wglUseFontBitmapsA;
    alias wglUseFontOutlines = wglUseFontOutlinesA;
    static if (_WIN32_WINNT >= 0x500) {
        alias ENUMLOGFONTEXDV = ENUMLOGFONTEXDVA;
        alias PENUMLOGFONTEXDV = PENUMLOGFONTEXDVA;
        alias LPENUMLOGFONTEXDV = LPENUMLOGFONTEXDVA;
        alias AddFontResourceEx = AddFontResourceExA;
        alias RemoveFontResourceEx = RemoveFontResourceExA;
        alias GetGlyphIndices = GetGlyphIndicesA;
    }
}

// Common to both ASCII & UNICODE
alias LPDOCINFO = DOCINFO*;
alias PLOGFONT = LOGFONT*, NPLOGFONT = LOGFONT*, LPLOGFONT = LOGFONT*;
alias PTEXTMETRIC = TEXTMETRIC*, LPTEXTMETRIC = TEXTMETRIC*;
alias PDEVMODE = DEVMODE*, NPDEVMODE = DEVMODE*, LPDEVMODE = DEVMODE*;
alias PEXTLOGFONT = EXTLOGFONT*, NPEXTLOGFONT = EXTLOGFONT*, LPEXTLOGFONT = EXTLOGFONT*;
alias LPGCP_RESULTS = GCP_RESULTS*;
alias POUTLINETEXTMETRIC = OUTLINETEXTMETRIC*, NPOUTLINETEXTMETRIC = OUTLINETEXTMETRIC*, LPOUTLINETEXTMETRIC = OUTLINETEXTMETRIC*;
alias PPOLYTEXT = POLYTEXT*, NPPOLYTEXT = POLYTEXT*, LPPOLYTEXT = POLYTEXT*;
alias LPLOGCOLORSPACE = LOGCOLORSPACE*;
alias PNEWTEXTMETRIC = NEWTEXTMETRIC*, NPNEWTEXTMETRIC = NEWTEXTMETRIC*, LPNEWTEXTMETRIC = NEWTEXTMETRIC*;
alias LPENUMLOGFONT = ENUMLOGFONT*;
alias LPENUMLOGFONTEX = ENUMLOGFONTEX*;
alias PDISPLAY_DEVICE = DISPLAY_DEVICE*, LPDISPLAY_DEVICE = DISPLAY_DEVICE*;
