PageRenderTime 466ms CodeModel.GetById 47ms app.highlight 385ms RepoModel.GetById 1ms app.codeStats 2ms

/binding/win32/wingdi.d

http://github.com/wilkie/djehuty
D | 5612 lines | 4450 code | 885 blank | 277 comment | 72 complexity | f3a6255c8f1fbd462b2ff68ba5d6885c MD5 | raw file
   1/*
   2 * wingdi.d
   3 *
   4 * This module binds wingdi.h to D. The original copyright notice is
   5 * preserved below.
   6 *
   7 * Author: Dave Wilkinson
   8 * Originated: November 24th, 2009
   9 *
  10 */
  11
  12module binding.win32.wingdi;
  13
  14import binding.win32.windef;
  15import binding.win32.winnt;
  16import binding.win32.winuser;
  17
  18import binding.c;
  19
  20extern(System):
  21
  22// The original copyright from WinGDI.h:
  23
  24/**************************************************************************
  25*                                                                         *
  26* wingdi.h -- GDI procedure declarations, constant definitions and macros *
  27*                                                                         *
  28* Copyright (c) Microsoft Corp. All rights reserved.                      *
  29*                                                                         *
  30**************************************************************************/
  31
  32/* Binary raster ops */
  33const auto R2_BLACK            = 1;   /*  0       */
  34const auto R2_NOTMERGEPEN      = 2;   /* DPon     */
  35const auto R2_MASKNOTPEN       = 3;   /* DPna     */
  36const auto R2_NOTCOPYPEN       = 4;   /* PN       */
  37const auto R2_MASKPENNOT       = 5;   /* PDna     */
  38const auto R2_NOT              = 6;   /* Dn       */
  39const auto R2_XORPEN           = 7;   /* DPx      */
  40const auto R2_NOTMASKPEN       = 8;   /* DPan     */
  41const auto R2_MASKPEN          = 9;   /* DPa      */
  42const auto R2_NOTXORPEN        = 10;  /* DPxn     */
  43const auto R2_NOP              = 11;  /* D        */
  44const auto R2_MERGENOTPEN      = 12;  /* DPno     */
  45const auto R2_COPYPEN          = 13;  /* P        */
  46const auto R2_MERGEPENNOT      = 14;  /* PDno     */
  47const auto R2_MERGEPEN         = 15;  /* DPo      */
  48const auto R2_WHITE            = 16;  /*  1       */
  49const auto R2_LAST             = 16;
  50
  51/* Ternary raster operations */
  52const auto SRCCOPY             = cast(DWORD)0x00CC0020; /* dest = source                   */
  53const auto SRCPAINT            = cast(DWORD)0x00EE0086; /* dest = source OR dest           */
  54const auto SRCAND              = cast(DWORD)0x008800C6; /* dest = source AND dest          */
  55const auto SRCINVERT           = cast(DWORD)0x00660046; /* dest = source XOR dest          */
  56const auto SRCERASE            = cast(DWORD)0x00440328; /* dest = source AND (NOT dest )   */
  57const auto NOTSRCCOPY          = cast(DWORD)0x00330008; /* dest = (NOT source)             */
  58const auto NOTSRCERASE         = cast(DWORD)0x001100A6; /* dest = (NOT src) AND (NOT dest) */
  59const auto MERGECOPY           = cast(DWORD)0x00C000CA; /* dest = (source AND pattern)     */
  60const auto MERGEPAINT          = cast(DWORD)0x00BB0226; /* dest = (NOT source) OR dest     */
  61const auto PATCOPY             = cast(DWORD)0x00F00021; /* dest = pattern                  */
  62const auto PATPAINT            = cast(DWORD)0x00FB0A09; /* dest = DPSnoo                   */
  63const auto PATINVERT           = cast(DWORD)0x005A0049; /* dest = pattern XOR dest         */
  64const auto DSTINVERT           = cast(DWORD)0x00550009; /* dest = (NOT dest)               */
  65const auto BLACKNESS           = cast(DWORD)0x00000042; /* dest = BLACK                    */
  66const auto WHITENESS           = cast(DWORD)0x00FF0062; /* dest = WHITE                    */
  67
  68const auto NOMIRRORBITMAP      = cast(DWORD)0x80000000; /* Do not Mirror the bitmap in this call */
  69const auto CAPTUREBLT          = cast(DWORD)0x40000000; /* Include layered windows */
  70
  71/* Quaternary raster codes */
  72template MAKEROP4(uint fore, uint back) {
  73	const uint MAKEROP4 = cast(uint)((((back) << 8) & 0xFF000000) | (fore));
  74}
  75
  76const auto GDI_ERROR = (0xFFFFFFFFL);
  77
  78const auto HGDI_ERROR = cast(HANDLE)(-1);
  79
  80/* Region Flags */
  81const auto ERROR				= 0;
  82const auto NULLREGION			= 1;
  83const auto SIMPLEREGION			= 2;
  84const auto COMPLEXREGION		= 3;
  85const auto RGN_ERROR 			= ERROR;
  86
  87/* CombineRgn() Styles */
  88const auto RGN_AND             = 1;
  89const auto RGN_OR              = 2;
  90const auto RGN_XOR             = 3;
  91const auto RGN_DIFF            = 4;
  92const auto RGN_COPY            = 5;
  93const auto RGN_MIN             = RGN_AND;
  94const auto RGN_MAX             = RGN_COPY;
  95
  96/* StretchBlt() Modes */
  97const auto BLACKONWHITE                 = 1;
  98const auto WHITEONBLACK                 = 2;
  99const auto COLORONCOLOR                 = 3;
 100const auto HALFTONE                     = 4;
 101const auto MAXSTRETCHBLTMODE            = 4;
 102
 103/* New StretchBlt() Modes */
 104const auto STRETCH_ANDSCANS    = BLACKONWHITE;
 105const auto STRETCH_ORSCANS     = WHITEONBLACK;
 106const auto STRETCH_DELETESCANS = COLORONCOLOR;
 107const auto STRETCH_HALFTONE    = HALFTONE;
 108
 109/* PolyFill() Modes */
 110const auto ALTERNATE                    = 1;
 111const auto WINDING                      = 2;
 112const auto POLYFILL_LAST                = 2;
 113
 114/* Layout Orientation Options */
 115const auto LAYOUT_RTL                         = 0x00000001; // Right to left
 116const auto LAYOUT_BTT                         = 0x00000002; // Bottom to top
 117const auto LAYOUT_VBH                         = 0x00000004; // Vertical before horizontal
 118const auto LAYOUT_ORIENTATIONMASK             = (LAYOUT_RTL | LAYOUT_BTT | LAYOUT_VBH);
 119const auto LAYOUT_BITMAPORIENTATIONPRESERVED  = 0x00000008;
 120
 121/* Text Alignment Options */
 122const auto TA_NOUPDATECP                = 0;
 123const auto TA_UPDATECP                  = 1;
 124
 125const auto TA_LEFT                      = 0;
 126const auto TA_RIGHT                     = 2;
 127const auto TA_CENTER                    = 6;
 128
 129const auto TA_TOP                       = 0;
 130const auto TA_BOTTOM                    = 8;
 131const auto TA_BASELINE                  = 24;
 132
 133const auto TA_RTLREADING                = 256;
 134const auto TA_MASK       = (TA_BASELINE+TA_CENTER+TA_UPDATECP+TA_RTLREADING);
 135
 136const auto VTA_BASELINE = TA_BASELINE;
 137const auto VTA_LEFT     = TA_BOTTOM;
 138const auto VTA_RIGHT    = TA_TOP;
 139const auto VTA_CENTER   = TA_CENTER;
 140const auto VTA_BOTTOM   = TA_RIGHT;
 141const auto VTA_TOP      = TA_LEFT;
 142
 143const auto ETO_OPAQUE                   = 0x0002;
 144const auto ETO_CLIPPED                  = 0x0004;
 145
 146const auto ETO_GLYPH_INDEX              = 0x0010;
 147const auto ETO_RTLREADING               = 0x0080;
 148const auto ETO_NUMERICSLOCAL            = 0x0400;
 149const auto ETO_NUMERICSLATIN            = 0x0800;
 150const auto ETO_IGNORELANGUAGE           = 0x1000;
 151
 152const auto ETO_PDY                      = 0x2000;
 153const auto ETO_REVERSE_INDEX_MAP        = 0x10000;
 154
 155const auto ASPECT_FILTERING             = 0x0001;
 156
 157/* Bounds Accumulation APIs */
 158
 159const auto DCB_RESET       = 0x0001;
 160const auto DCB_ACCUMULATE  = 0x0002;
 161const auto DCB_DIRTY       = DCB_ACCUMULATE;
 162const auto DCB_SET         = (DCB_RESET | DCB_ACCUMULATE);
 163const auto DCB_ENABLE      = 0x0004;
 164const auto DCB_DISABLE     = 0x0008;
 165
 166/* Metafile Functions */
 167const auto META_SETBKCOLOR              = 0x0201;
 168const auto META_SETBKMODE               = 0x0102;
 169const auto META_SETMAPMODE              = 0x0103;
 170const auto META_SETROP2                 = 0x0104;
 171const auto META_SETRELABS               = 0x0105;
 172const auto META_SETPOLYFILLMODE         = 0x0106;
 173const auto META_SETSTRETCHBLTMODE       = 0x0107;
 174const auto META_SETTEXTCHAREXTRA        = 0x0108;
 175const auto META_SETTEXTCOLOR            = 0x0209;
 176const auto META_SETTEXTJUSTIFICATION    = 0x020A;
 177const auto META_SETWINDOWORG            = 0x020B;
 178const auto META_SETWINDOWEXT            = 0x020C;
 179const auto META_SETVIEWPORTORG          = 0x020D;
 180const auto META_SETVIEWPORTEXT          = 0x020E;
 181const auto META_OFFSETWINDOWORG         = 0x020F;
 182const auto META_SCALEWINDOWEXT          = 0x0410;
 183const auto META_OFFSETVIEWPORTORG       = 0x0211;
 184const auto META_SCALEVIEWPORTEXT        = 0x0412;
 185const auto META_LINETO                  = 0x0213;
 186const auto META_MOVETO                  = 0x0214;
 187const auto META_EXCLUDECLIPRECT         = 0x0415;
 188const auto META_INTERSECTCLIPRECT       = 0x0416;
 189const auto META_ARC                     = 0x0817;
 190const auto META_ELLIPSE                 = 0x0418;
 191const auto META_FLOODFILL               = 0x0419;
 192const auto META_PIE                     = 0x081A;
 193const auto META_RECTANGLE               = 0x041B;
 194const auto META_ROUNDRECT               = 0x061C;
 195const auto META_PATBLT                  = 0x061D;
 196const auto META_SAVEDC                  = 0x001E;
 197const auto META_SETPIXEL                = 0x041F;
 198const auto META_OFFSETCLIPRGN           = 0x0220;
 199const auto META_TEXTOUT                 = 0x0521;
 200const auto META_BITBLT                  = 0x0922;
 201const auto META_STRETCHBLT              = 0x0B23;
 202const auto META_POLYGON                 = 0x0324;
 203const auto META_POLYLINE                = 0x0325;
 204const auto META_ESCAPE                  = 0x0626;
 205const auto META_RESTOREDC               = 0x0127;
 206const auto META_FILLREGION              = 0x0228;
 207const auto META_FRAMEREGION             = 0x0429;
 208const auto META_INVERTREGION            = 0x012A;
 209const auto META_PAINTREGION             = 0x012B;
 210const auto META_SELECTCLIPREGION        = 0x012C;
 211const auto META_SELECTOBJECT            = 0x012D;
 212const auto META_SETTEXTALIGN            = 0x012E;
 213const auto META_CHORD                   = 0x0830;
 214const auto META_SETMAPPERFLAGS          = 0x0231;
 215const auto META_EXTTEXTOUT              = 0x0a32;
 216const auto META_SETDIBTODEV             = 0x0d33;
 217const auto META_SELECTPALETTE           = 0x0234;
 218const auto META_REALIZEPALETTE          = 0x0035;
 219const auto META_ANIMATEPALETTE          = 0x0436;
 220const auto META_SETPALENTRIES           = 0x0037;
 221const auto META_POLYPOLYGON             = 0x0538;
 222const auto META_RESIZEPALETTE           = 0x0139;
 223const auto META_DIBBITBLT               = 0x0940;
 224const auto META_DIBSTRETCHBLT           = 0x0b41;
 225const auto META_DIBCREATEPATTERNBRUSH   = 0x0142;
 226const auto META_STRETCHDIB              = 0x0f43;
 227const auto META_EXTFLOODFILL            = 0x0548;
 228
 229const auto META_SETLAYOUT               = 0x0149;
 230
 231const auto META_DELETEOBJECT            = 0x01f0;
 232const auto META_CREATEPALETTE           = 0x00f7;
 233const auto META_CREATEPATTERNBRUSH      = 0x01F9;
 234const auto META_CREATEPENINDIRECT       = 0x02FA;
 235const auto META_CREATEFONTINDIRECT      = 0x02FB;
 236const auto META_CREATEBRUSHINDIRECT     = 0x02FC;
 237const auto META_CREATEREGION            = 0x06FF;
 238
 239struct DRAWPATRECT {
 240	POINT ptPosition;
 241	POINT ptSize;
 242	WORD wStyle;
 243	WORD wPattern;
 244}
 245
 246typedef DRAWPATRECT* PDRAWPATRECT;
 247
 248/* GDI Escapes */
 249const auto NEWFRAME                     = 1;
 250const auto ABORTDOC                     = 2;
 251const auto NEXTBAND                     = 3;
 252const auto SETCOLORTABLE                = 4;
 253const auto GETCOLORTABLE                = 5;
 254const auto FLUSHOUTPUT                  = 6;
 255const auto DRAFTMODE                    = 7;
 256const auto QUERYESCSUPPORT              = 8;
 257const auto SETABORTPROC                 = 9;
 258const auto STARTDOC                     = 10;
 259const auto ENDDOC                       = 11;
 260const auto GETPHYSPAGESIZE              = 12;
 261const auto GETPRINTINGOFFSET            = 13;
 262const auto GETSCALINGFACTOR             = 14;
 263const auto MFCOMMENT                    = 15;
 264const auto GETPENWIDTH                  = 16;
 265const auto SETCOPYCOUNT                 = 17;
 266const auto SELECTPAPERSOURCE            = 18;
 267const auto DEVICEDATA                   = 19;
 268const auto PASSTHROUGH                  = 19;
 269const auto GETTECHNOLGY                 = 20;
 270const auto GETTECHNOLOGY                = 20;
 271const auto SETLINECAP                   = 21;
 272const auto SETLINEJOIN                  = 22;
 273const auto SETMITERLIMIT                = 23;
 274const auto BANDINFO                     = 24;
 275const auto DRAWPATTERNRECT              = 25;
 276const auto GETVECTORPENSIZE             = 26;
 277const auto GETVECTORBRUSHSIZE           = 27;
 278const auto ENABLEDUPLEX                 = 28;
 279const auto GETSETPAPERBINS              = 29;
 280const auto GETSETPRINTORIENT            = 30;
 281const auto ENUMPAPERBINS                = 31;
 282const auto SETDIBSCALING                = 32;
 283const auto EPSPRINTING                  = 33;
 284const auto ENUMPAPERMETRICS             = 34;
 285const auto GETSETPAPERMETRICS           = 35;
 286const auto POSTSCRIPT_DATA              = 37;
 287const auto POSTSCRIPT_IGNORE            = 38;
 288const auto MOUSETRAILS                  = 39;
 289const auto GETDEVICEUNITS               = 42;
 290
 291const auto GETEXTENDEDTEXTMETRICS       = 256;
 292const auto GETEXTENTTABLE               = 257;
 293const auto GETPAIRKERNTABLE             = 258;
 294const auto GETTRACKKERNTABLE            = 259;
 295const auto EXTTEXTOUT                   = 512;
 296const auto GETFACENAME                  = 513;
 297const auto DOWNLOADFACE                 = 514;
 298const auto ENABLERELATIVEWIDTHS         = 768;
 299const auto ENABLEPAIRKERNING            = 769;
 300const auto SETKERNTRACK                 = 770;
 301const auto SETALLJUSTVALUES             = 771;
 302const auto SETCHARSET                   = 772;
 303
 304const auto STRETCHBLT                   = 2048;
 305const auto METAFILE_DRIVER              = 2049;
 306const auto GETSETSCREENPARAMS           = 3072;
 307const auto QUERYDIBSUPPORT              = 3073;
 308const auto BEGIN_PATH                   = 4096;
 309const auto CLIP_TO_PATH                 = 4097;
 310const auto END_PATH                     = 4098;
 311const auto EXT_DEVICE_CAPS              = 4099;
 312const auto RESTORE_CTM                  = 4100;
 313const auto SAVE_CTM                     = 4101;
 314const auto SET_ARC_DIRECTION            = 4102;
 315const auto SET_BACKGROUND_COLOR         = 4103;
 316const auto SET_POLY_MODE                = 4104;
 317const auto SET_SCREEN_ANGLE             = 4105;
 318const auto SET_SPREAD                   = 4106;
 319const auto TRANSFORM_CTM                = 4107;
 320const auto SET_CLIP_BOX                 = 4108;
 321const auto SET_BOUNDS                   = 4109;
 322const auto SET_MIRROR_MODE              = 4110;
 323const auto OPENCHANNEL                  = 4110;
 324const auto DOWNLOADHEADER               = 4111;
 325const auto CLOSECHANNEL                 = 4112;
 326const auto POSTSCRIPT_PASSTHROUGH       = 4115;
 327const auto ENCAPSULATED_POSTSCRIPT      = 4116;
 328
 329const auto POSTSCRIPT_IDENTIFY          = 4117;   /* new escape for NT5 pscript driver */
 330const auto POSTSCRIPT_INJECTION         = 4118;   /* new escape for NT5 pscript driver */
 331
 332const auto CHECKJPEGFORMAT              = 4119;
 333const auto CHECKPNGFORMAT               = 4120;
 334
 335const auto GET_PS_FEATURESETTING        = 4121;   /* new escape for NT5 pscript driver */
 336
 337const auto GDIPLUS_TS_QUERYVER          = 4122;   /* private escape */
 338const auto GDIPLUS_TS_RECORD            = 4123;   /* private escape */
 339
 340/*
 341 * Return Values for MILCORE_TS_QUERYVER
 342 */
 343
 344const auto MILCORE_TS_QUERYVER_RESULT_FALSE = 0x0;
 345const auto MILCORE_TS_QUERYVER_RESULT_TRUE  = 0x7FFFFFFF;
 346
 347const auto SPCLPASSTHROUGH2             = 4568;   /* new escape for NT5 pscript driver */
 348
 349/*
 350 * Parameters for POSTSCRIPT_IDENTIFY escape
 351 */
 352
 353const auto PSIDENT_GDICENTRIC    = 0;
 354const auto PSIDENT_PSCENTRIC     = 1;
 355
 356/*
 357 * Header structure for the input buffer to POSTSCRIPT_INJECTION escape
 358 */
 359
 360struct PSINJECTDATA {
 361
 362    DWORD   DataBytes;      /* number of raw data bytes (NOT including this header) */
 363    WORD    InjectionPoint; /* injection point */
 364    WORD    PageNumber;     /* page number to apply the injection */
 365
 366    /* Followed by raw data to be injected */
 367
 368}
 369
 370typedef PSINJECTDATA* PPSINJECTDATA;
 371
 372/*
 373 * Constants for PSINJECTDATA.InjectionPoint field
 374 */
 375
 376const auto PSINJECT_BEGINSTREAM                = 1;
 377const auto PSINJECT_PSADOBE                    = 2;
 378const auto PSINJECT_PAGESATEND                 = 3;
 379const auto PSINJECT_PAGES                      = 4;
 380
 381const auto PSINJECT_DOCNEEDEDRES               = 5;
 382const auto PSINJECT_DOCSUPPLIEDRES             = 6;
 383const auto PSINJECT_PAGEORDER                  = 7;
 384const auto PSINJECT_ORIENTATION                = 8;
 385const auto PSINJECT_BOUNDINGBOX                = 9;
 386const auto PSINJECT_DOCUMENTPROCESSCOLORS      = 10;
 387
 388const auto PSINJECT_COMMENTS                   = 11;
 389const auto PSINJECT_BEGINDEFAULTS              = 12;
 390const auto PSINJECT_ENDDEFAULTS                = 13;
 391const auto PSINJECT_BEGINPROLOG                = 14;
 392const auto PSINJECT_ENDPROLOG                  = 15;
 393const auto PSINJECT_BEGINSETUP                 = 16;
 394const auto PSINJECT_ENDSETUP                   = 17;
 395const auto PSINJECT_TRAILER                    = 18;
 396const auto PSINJECT_EOF                        = 19;
 397const auto PSINJECT_ENDSTREAM                  = 20;
 398const auto PSINJECT_DOCUMENTPROCESSCOLORSATEND = 21;
 399
 400const auto PSINJECT_PAGENUMBER                 = 100;
 401const auto PSINJECT_BEGINPAGESETUP             = 101;
 402const auto PSINJECT_ENDPAGESETUP               = 102;
 403const auto PSINJECT_PAGETRAILER                = 103;
 404const auto PSINJECT_PLATECOLOR                 = 104;
 405
 406const auto PSINJECT_SHOWPAGE                   = 105;
 407const auto PSINJECT_PAGEBBOX                   = 106;
 408const auto PSINJECT_ENDPAGECOMMENTS            = 107;
 409
 410const auto PSINJECT_VMSAVE                     = 200;
 411const auto PSINJECT_VMRESTORE                  = 201;
 412
 413/*
 414 * Parameter for GET_PS_FEATURESETTING escape
 415 */
 416
 417const auto FEATURESETTING_NUP                  = 0;
 418const auto FEATURESETTING_OUTPUT               = 1;
 419const auto FEATURESETTING_PSLEVEL              = 2;
 420const auto FEATURESETTING_CUSTPAPER            = 3;
 421const auto FEATURESETTING_MIRROR               = 4;
 422const auto FEATURESETTING_NEGATIVE             = 5;
 423const auto FEATURESETTING_PROTOCOL             = 6;
 424
 425//
 426// The range of selectors between FEATURESETTING_PRIVATE_BEGIN and
 427// FEATURESETTING_PRIVATE_END is reserved by Microsoft for private use
 428//
 429const auto FEATURESETTING_PRIVATE_BEGIN = 0x1000;
 430const auto FEATURESETTING_PRIVATE_END   = 0x1FFF;
 431
 432/*
 433 * Information about output options
 434 */
 435
 436struct PSFEATURE_OUTPUT {
 437    BOOL bPageIndependent;
 438    BOOL bSetPageDevice;
 439}
 440
 441typedef PSFEATURE_OUTPUT* PPSFEATURE_OUTPUT;
 442
 443/*
 444 * Information about custom paper size
 445 */
 446
 447struct PSFEATURE_CUSTPAPER {
 448	LONG lOrientation;
 449	LONG lWidth;
 450	LONG lHeight;
 451	LONG lWidthOffset;
 452	LONG lHeightOffset;
 453
 454}
 455
 456typedef PSFEATURE_CUSTPAPER* PPSFEATURE_CUSTPAPER;
 457
 458/* Value returned for FEATURESETTING_PROTOCOL */
 459const auto PSPROTOCOL_ASCII             = 0;
 460const auto PSPROTOCOL_BCP               = 1;
 461const auto PSPROTOCOL_TBCP              = 2;
 462const auto PSPROTOCOL_BINARY            = 3;
 463
 464/* Flag returned from QUERYDIBSUPPORT */
 465const auto QDI_SETDIBITS                = 1;
 466const auto QDI_GETDIBITS                = 2;
 467const auto QDI_DIBTOSCREEN              = 4;
 468const auto QDI_STRETCHDIB               = 8;
 469
 470/* Spooler Error Codes */
 471const auto SP_NOTREPORTED               = 0x4000;
 472const auto SP_ERROR                     = (-1);
 473const auto SP_APPABORT                  = (-2);
 474const auto SP_USERABORT                 = (-3);
 475const auto SP_OUTOFDISK                 = (-4);
 476const auto SP_OUTOFMEMORY               = (-5);
 477
 478const auto PR_JOBSTATUS                 = 0x0000;
 479
 480/* Object Definitions for EnumObjects() */
 481const auto OBJ_PEN             = 1;
 482const auto OBJ_BRUSH           = 2;
 483const auto OBJ_DC              = 3;
 484const auto OBJ_METADC          = 4;
 485const auto OBJ_PAL             = 5;
 486const auto OBJ_FONT            = 6;
 487const auto OBJ_BITMAP          = 7;
 488const auto OBJ_REGION          = 8;
 489const auto OBJ_METAFILE        = 9;
 490const auto OBJ_MEMDC           = 10;
 491const auto OBJ_EXTPEN          = 11;
 492const auto OBJ_ENHMETADC       = 12;
 493const auto OBJ_ENHMETAFILE     = 13;
 494const auto OBJ_COLORSPACE      = 14;
 495
 496const auto GDI_OBJ_LAST        = OBJ_COLORSPACE;
 497
 498/* xform stuff */
 499const auto MWT_IDENTITY        = 1;
 500const auto MWT_LEFTMULTIPLY    = 2;
 501const auto MWT_RIGHTMULTIPLY   = 3;
 502
 503const auto MWT_MIN             = MWT_IDENTITY;
 504const auto MWT_MAX             = MWT_RIGHTMULTIPLY;
 505
 506const auto _XFORM_ = 0;
 507struct XFORM {
 508	FLOAT   eM11;
 509	FLOAT   eM12;
 510	FLOAT   eM21;
 511	FLOAT   eM22;
 512	FLOAT   eDx;
 513	FLOAT   eDy;
 514}
 515
 516typedef XFORM* PXFORM;
 517typedef XFORM* LPXFORM;
 518
 519/* Bitmap Header Definition */
 520struct BITMAP {
 521	LONG        bmType;
 522	LONG        bmWidth;
 523	LONG        bmHeight;
 524	LONG        bmWidthBytes;
 525	WORD        bmPlanes;
 526	WORD        bmBitsPixel;
 527	LPVOID      bmBits;
 528}
 529
 530typedef BITMAP* PBITMAP;
 531typedef BITMAP* NPBITMAP;
 532typedef BITMAP* LPBITMAP;
 533
 534align(1) struct RGBTRIPLE {
 535	BYTE    rgbtBlue;
 536	BYTE    rgbtGreen;
 537	BYTE    rgbtRed;
 538} 
 539
 540typedef RGBTRIPLE* PRGBTRIPLE;
 541typedef RGBTRIPLE* NPRGBTRIPLE;
 542typedef RGBTRIPLE* LPRGBTRIPLE;
 543
 544struct RGBQUAD {
 545	BYTE    rgbBlue;
 546	BYTE    rgbGreen;
 547	BYTE    rgbRed;
 548	BYTE    rgbReserved;
 549}
 550typedef RGBQUAD* LPRGBQUAD;
 551
 552/* Image Color Matching color definitions */
 553
 554const auto CS_ENABLE                       = 0x00000001;
 555const auto CS_DISABLE                      = 0x00000002;
 556const auto CS_DELETE_TRANSFORM             = 0x00000003;
 557
 558/* Logcolorspace signature */
 559
 560const auto LCS_SIGNATURE           = "PSOC"c;
 561
 562/* Logcolorspace lcsType values */
 563
 564const auto LCS_sRGB                = "sRGB"c;
 565const auto LCS_WINDOWS_COLOR_SPACE = "Win "c;  // Windows default color space
 566
 567typedef LONG LCSCSTYPE;
 568const auto LCS_CALIBRATED_RGB              = 0x00000000;
 569
 570typedef LONG LCSGAMUTMATCH;
 571const auto LCS_GM_BUSINESS                 = 0x00000001;
 572const auto LCS_GM_GRAPHICS                 = 0x00000002;
 573const auto LCS_GM_IMAGES                   = 0x00000004;
 574const auto LCS_GM_ABS_COLORIMETRIC         = 0x00000008;
 575
 576/* ICM Defines for results from CheckColorInGamut() */
 577const auto CM_OUT_OF_GAMUT                 = 255;
 578const auto CM_IN_GAMUT                     = 0;
 579
 580/* UpdateICMRegKey Constants               */
 581const auto ICM_ADDPROFILE                  = 1;
 582const auto ICM_DELETEPROFILE               = 2;
 583const auto ICM_QUERYPROFILE                = 3;
 584const auto ICM_SETDEFAULTPROFILE           = 4;
 585const auto ICM_REGISTERICMATCHER           = 5;
 586const auto ICM_UNREGISTERICMATCHER         = 6;
 587const auto ICM_QUERYMATCH                  = 7;
 588
 589/* Macros to retrieve CMYK values from a COLORREF */
 590template GetKValue(COLORREF cmyk) {
 591	const BYTE GetKValue = cast(BYTE)(cmyk);
 592}
 593
 594template GetYValue(COLORREF cmyk) {
 595	const BYTE GetYValue = cast(BYTE)(cmyk >> 8);
 596}
 597
 598template GetYValue(COLORREF cmyk) {
 599	const BYTE GetMValue = cast(BYTE)(cmyk >> 16);
 600}
 601
 602template GetYValue(COLORREF cmyk) {
 603	const BYTE GetCValue = cast(BYTE)(cmyk >> 24);
 604}
 605
 606template CMYK(BYTE c, BYTE m, BYTE y, BYTE k) {
 607	const COLORREF CMYK = cast(COLORREF)(cast(uint)k | (cast(uint)y) << 8 | (cast(uint)m) << 16 | (cast(uint)c) << 24);
 608}
 609
 610typedef Clong_t FXPT16DOT16;
 611typedef Clong_t* LPFXPT16DOT16;
 612typedef Clong_t FXPT2DOT30;
 613typedef Clong_t* LPFXPT2DOT30;
 614
 615/* ICM Color Definitions */
 616// The following two structures are used for defining RGB's in terms of CIEXYZ.
 617
 618struct CIEXYZ {
 619	FXPT2DOT30 ciexyzX;
 620	FXPT2DOT30 ciexyzY;
 621	FXPT2DOT30 ciexyzZ;
 622}
 623
 624typedef CIEXYZ* LPCIEXYZ;
 625
 626struct CIEXYZTRIPLE {
 627	CIEXYZ  ciexyzRed;
 628	CIEXYZ  ciexyzGreen;
 629	CIEXYZ  ciexyzBlue;
 630}
 631
 632typedef CIEXYZTRIPLE* LPCIEXYZTRIPLE;
 633
 634// The next structures the logical color space. Unlike pens and brushes,
 635// but like palettes, there is only one way to create a LogColorSpace.
 636// A pointer to it must be passed, its elements can't be pushed as
 637// arguments.
 638
 639struct LOGCOLORSPACEA {
 640	DWORD lcsSignature;
 641	DWORD lcsVersion;
 642    DWORD lcsSize;
 643    LCSCSTYPE lcsCSType;
 644    LCSGAMUTMATCH lcsIntent;
 645    CIEXYZTRIPLE lcsEndpoints;
 646    DWORD lcsGammaRed;
 647    DWORD lcsGammaGreen;
 648    DWORD lcsGammaBlue;
 649    CHAR   lcsFilename[MAX_PATH];
 650}
 651
 652typedef LOGCOLORSPACEA* LPLOGCOLORSPACEA;
 653
 654struct LOGCOLORSPACEW {
 655    DWORD lcsSignature;
 656    DWORD lcsVersion;
 657    DWORD lcsSize;
 658    LCSCSTYPE lcsCSType;
 659    LCSGAMUTMATCH lcsIntent;
 660    CIEXYZTRIPLE lcsEndpoints;
 661    DWORD lcsGammaRed;
 662    DWORD lcsGammaGreen;
 663    DWORD lcsGammaBlue;
 664    WCHAR  lcsFilename[MAX_PATH];
 665}
 666
 667typedef LOGCOLORSPACEW* LPLOGCOLORSPACEW;
 668
 669version(UNICODE) {
 670	typedef LOGCOLORSPACEW LOGCOLORSPACE;
 671	typedef LPLOGCOLORSPACEW LPLOGCOLORSPACE;
 672}
 673else {
 674	typedef LOGCOLORSPACEA LOGCOLORSPACE;
 675	typedef LPLOGCOLORSPACEA LPLOGCOLORSPACE;
 676}
 677
 678/* structures for defining DIBs */
 679struct BITMAPCOREHEADER {
 680	DWORD   bcSize;                 /* used to get to color table */
 681	WORD    bcWidth;
 682	WORD    bcHeight;
 683	WORD    bcPlanes;
 684	WORD    bcBitCount;
 685} 
 686
 687typedef BITMAPCOREHEADER* LPBITMAPCOREHEADER;
 688typedef BITMAPCOREHEADER* PBITMAPCOREHEADER;
 689
 690struct BITMAPINFOHEADER{
 691	DWORD      biSize;
 692	LONG       biWidth;
 693	LONG       biHeight;
 694	WORD       biPlanes;
 695	WORD       biBitCount;
 696	DWORD      biCompression;
 697	DWORD      biSizeImage;
 698	LONG       biXPelsPerMeter;
 699	LONG       biYPelsPerMeter;
 700	DWORD      biClrUsed;
 701	DWORD      biClrImportant;
 702} 
 703
 704typedef BITMAPINFOHEADER* LPBITMAPINFOHEADER;
 705typedef BITMAPINFOHEADER* PBITMAPINFOHEADER;
 706
 707struct BITMAPV4HEADER {
 708	DWORD        bV4Size;
 709	LONG         bV4Width;
 710	LONG         bV4Height;
 711	WORD         bV4Planes;
 712	WORD         bV4BitCount;
 713	DWORD        bV4V4Compression;
 714	DWORD        bV4SizeImage;
 715	LONG         bV4XPelsPerMeter;
 716	LONG         bV4YPelsPerMeter;
 717	DWORD        bV4ClrUsed;
 718	DWORD        bV4ClrImportant;
 719	DWORD        bV4RedMask;
 720	DWORD        bV4GreenMask;
 721	DWORD        bV4BlueMask;
 722	DWORD        bV4AlphaMask;
 723	DWORD        bV4CSType;
 724	CIEXYZTRIPLE bV4Endpoints;
 725	DWORD        bV4GammaRed;
 726	DWORD        bV4GammaGreen;
 727	DWORD        bV4GammaBlue;
 728}
 729
 730typedef BITMAPV4HEADER* LPBITMAPV4HEADER;
 731typedef BITMAPV4HEADER* PBITMAPV4HEADER;
 732
 733struct BITMAPV5HEADER {
 734	DWORD        bV5Size;
 735	LONG         bV5Width;
 736	LONG         bV5Height;
 737	WORD         bV5Planes;
 738	WORD         bV5BitCount;
 739	DWORD        bV5Compression;
 740	DWORD        bV5SizeImage;
 741	LONG         bV5XPelsPerMeter;
 742	LONG         bV5YPelsPerMeter;
 743	DWORD        bV5ClrUsed;
 744	DWORD        bV5ClrImportant;
 745	DWORD        bV5RedMask;
 746	DWORD        bV5GreenMask;
 747	DWORD        bV5BlueMask;
 748	DWORD        bV5AlphaMask;
 749	DWORD        bV5CSType;
 750	CIEXYZTRIPLE bV5Endpoints;
 751	DWORD        bV5GammaRed;
 752	DWORD        bV5GammaGreen;
 753	DWORD        bV5GammaBlue;
 754	DWORD        bV5Intent;
 755	DWORD        bV5ProfileData;
 756	DWORD        bV5ProfileSize;
 757	DWORD        bV5Reserved;
 758}
 759
 760typedef BITMAPV5HEADER* LPBITMAPV5HEADER;
 761typedef BITMAPV5HEADER* PBITMAPV5HEADER;
 762
 763// Values for bV5CSType
 764const auto PROFILE_LINKED          = "LINK"c;
 765const auto PROFILE_EMBEDDED        = "MBED"c;
 766
 767/* constants for the biCompression field */
 768const auto BI_RGB        = 0;
 769const auto BI_RLE8       = 1;
 770const auto BI_RLE4       = 2;
 771const auto BI_BITFIELDS  = 3;
 772const auto BI_JPEG       = 4;
 773const auto BI_PNG        = 5;
 774
 775struct BITMAPINFO {
 776	BITMAPINFOHEADER    bmiHeader;
 777	RGBQUAD             bmiColors[1];
 778}
 779
 780typedef BITMAPINFO* LPBITMAPINFO;
 781typedef BITMAPINFO* PBITMAPINFO;
 782
 783struct BITMAPCOREINFO {
 784	BITMAPCOREHEADER    bmciHeader;
 785	RGBTRIPLE           bmciColors[1];
 786}
 787
 788typedef BITMAPCOREINFO* LPBITMAPCOREINFO;
 789typedef BITMAPCOREINFO* PBITMAPCOREINFO;
 790
 791align(2) struct BITMAPFILEHEADER {
 792	WORD    bfType;
 793	DWORD   bfSize;
 794	WORD    bfReserved1;
 795	WORD    bfReserved2;
 796	DWORD   bfOffBits;
 797}
 798typedef BITMAPFILEHEADER* LPBITMAPFILEHEADER;
 799typedef BITMAPFILEHEADER* PBITMAPFILEHEADER;
 800
 801POINTS* MAKEPOINTS(ref DWORD val) {
 802	return cast(POINTS*)(&val);
 803}
 804
 805struct FONTSIGNATURE {
 806	DWORD fsUsb[4];
 807	DWORD fsCsb[2];
 808}
 809
 810typedef FONTSIGNATURE* LPFONTSIGNATURE;
 811typedef FONTSIGNATURE* PFONTSIGNATURE;
 812
 813struct CHARSETINFO {
 814	UINT ciCharset;
 815	UINT ciACP;
 816	FONTSIGNATURE fs;
 817}
 818
 819typedef CHARSETINFO* NPCHARSETINFO;
 820typedef CHARSETINFO* LPCHARSETINFO;
 821typedef CHARSETINFO* PCHARSETINFO;
 822
 823const auto TCI_SRCCHARSET  = 1;
 824const auto TCI_SRCCODEPAGE = 2;
 825const auto TCI_SRCFONTSIG  = 3;
 826
 827const auto TCI_SRCLOCALE   = 0x1000;
 828
 829struct LOCALESIGNATURE {
 830	DWORD lsUsb[4];
 831	DWORD lsCsbDefault[2];
 832	DWORD lsCsbSupported[2];
 833}
 834
 835typedef LOCALESIGNATURE* LPLOCALESIGNATURE;
 836typedef LOCALESIGNATURE* PLOCALESIGNATURE;
 837
 838/* Clipboard Metafile Picture Structure */
 839struct HANDLETABLE {
 840	HGDIOBJ     objectHandle[1];
 841}
 842
 843typedef HANDLETABLE* PHANDLETABLE;
 844typedef HANDLETABLE* LPHANDLETABLE;
 845
 846struct METARECORD {
 847	DWORD       rdSize;
 848	WORD        rdFunction;
 849	WORD        rdParm[1];
 850}
 851typedef METARECORD* PMETARECORD;
 852typedef METARECORD* LPMETARECORD;
 853
 854struct METAFILEPICT {
 855	LONG        mm;
 856	LONG        xExt;
 857	LONG        yExt;
 858	HMETAFILE   hMF;
 859}
 860
 861typedef METAFILEPICT* LPMETAFILEPICT;
 862
 863align(2) struct METAHEADER {
 864	WORD        mtType;
 865	WORD        mtHeaderSize;
 866	WORD        mtVersion;
 867	DWORD       mtSize;
 868	WORD        mtNoObjects;
 869	DWORD       mtMaxRecord;
 870	WORD        mtNoParameters;
 871}
 872
 873typedef METAHEADER* PMETAHEADER;
 874typedef METAHEADER* LPMETAHEADER;
 875
 876/* Enhanced Metafile structures */
 877struct ENHMETARECORD {
 878	DWORD   iType;              // Record type EMR_XXX
 879	DWORD   nSize;              // Record size in bytes
 880	DWORD   dParm[1];           // Parameters
 881}
 882
 883typedef ENHMETARECORD* PENHMETARECORD;
 884typedef ENHMETARECORD* LPENHMETARECORD;
 885
 886struct ENHMETAHEADER {
 887	DWORD   iType;              // Record typeEMR_HEADER
 888	DWORD   nSize;              // Record size in bytes.  This may be greater
 889	                            // than the sizeof(ENHMETAHEADER).
 890	RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
 891	RECTL   rclFrame;           // Inclusive-inclusive Picture Frame of metafile in .01 mm units
 892	DWORD   dSignature;         // Signature.  Must be ENHMETA_SIGNATURE.
 893	DWORD   nVersion;           // Version number
 894	DWORD   nBytes;             // Size of the metafile in bytes
 895	DWORD   nRecords;           // Number of records in the metafile
 896	WORD    nHandles;           // Number of handles in the handle table
 897	                            // Handle index zero is reserved.
 898	WORD    sReserved;          // Reserved.  Must be zero.
 899	DWORD   nDescription;       // Number of chars in the unicode description string
 900	                            // This is 0 if there is no description string
 901	DWORD   offDescription;     // Offset to the metafile description record.
 902	                            // This is 0 if there is no description string
 903	DWORD   nPalEntries;        // Number of entries in the metafile palette.
 904	SIZEL   szlDevice;          // Size of the reference device in pels
 905	SIZEL   szlMillimeters;     // Size of the reference device in millimeters
 906	DWORD   cbPixelFormat;      // Size of PIXELFORMATDESCRIPTOR information
 907	                            // This is 0 if no pixel format is set
 908	DWORD   offPixelFormat;     // Offset to PIXELFORMATDESCRIPTOR
 909	                            // This is 0 if no pixel format is set
 910	DWORD   bOpenGL;            // TRUE if OpenGL commands are present in
 911	                            // the metafile, otherwise FALSE
 912	SIZEL   szlMicrometers;     // Size of the reference device in micrometers
 913}
 914
 915typedef ENHMETAHEADER* PENHMETAHEADER;
 916typedef ENHMETAHEADER* LPENHMETAHEADER;
 917
 918/* tmPitchAndFamily flags */
 919const auto TMPF_FIXED_PITCH	= 0x01;
 920const auto TMPF_VECTOR		= 0x02;
 921const auto TMPF_DEVICE		= 0x08;
 922const auto TMPF_TRUETYPE	= 0x04;
 923
 924//
 925// BCHAR definition for APPs
 926//
 927version(UNICODE) {
 928	typedef WCHAR BCHAR;
 929}
 930else {
 931	typedef BYTE BCHAR;
 932}
 933
 934align(4) struct TEXTMETRICA {
 935    LONG        tmHeight;
 936    LONG        tmAscent;
 937    LONG        tmDescent;
 938    LONG        tmInternalLeading;
 939    LONG        tmExternalLeading;
 940    LONG        tmAveCharWidth;
 941    LONG        tmMaxCharWidth;
 942    LONG        tmWeight;
 943    LONG        tmOverhang;
 944    LONG        tmDigitizedAspectX;
 945    LONG        tmDigitizedAspectY;
 946    BYTE        tmFirstChar;
 947    BYTE        tmLastChar;
 948    BYTE        tmDefaultChar;
 949    BYTE        tmBreakChar;
 950    BYTE        tmItalic;
 951    BYTE        tmUnderlined;
 952    BYTE        tmStruckOut;
 953    BYTE        tmPitchAndFamily;
 954    BYTE        tmCharSet;
 955}
 956
 957typedef TEXTMETRICA* PTEXTMETRICA;
 958typedef TEXTMETRICA* NPTEXTMETRICA;
 959typedef TEXTMETRICA* LPTEXTMETRICA;
 960
 961align(4) struct TEXTMETRICW {
 962    LONG        tmHeight;
 963    LONG        tmAscent;
 964    LONG        tmDescent;
 965    LONG        tmInternalLeading;
 966    LONG        tmExternalLeading;
 967    LONG        tmAveCharWidth;
 968    LONG        tmMaxCharWidth;
 969    LONG        tmWeight;
 970    LONG        tmOverhang;
 971    LONG        tmDigitizedAspectX;
 972    LONG        tmDigitizedAspectY;
 973    WCHAR       tmFirstChar;
 974    WCHAR       tmLastChar;
 975    WCHAR       tmDefaultChar;
 976    WCHAR       tmBreakChar;
 977    BYTE        tmItalic;
 978    BYTE        tmUnderlined;
 979    BYTE        tmStruckOut;
 980    BYTE        tmPitchAndFamily;
 981    BYTE        tmCharSet;
 982}
 983
 984typedef TEXTMETRICW* PTEXTMETRICW;
 985typedef TEXTMETRICW* NPTEXTMETRICW;
 986typedef TEXTMETRICW* LPTEXTMETRICW;
 987
 988version(UNICODE) {
 989	typedef TEXTMETRICW TEXTMETRIC;
 990	typedef PTEXTMETRICW PTEXTMETRIC;
 991	typedef NPTEXTMETRICW NPTEXTMETRIC;
 992	typedef LPTEXTMETRICW LPTEXTMETRIC;
 993}
 994else {
 995	typedef TEXTMETRICA TEXTMETRIC;
 996	typedef PTEXTMETRICA PTEXTMETRIC;
 997	typedef NPTEXTMETRICA NPTEXTMETRIC;
 998	typedef LPTEXTMETRICA LPTEXTMETRIC;
 999}
1000
1001/* ntmFlags field flags */
1002const auto NTM_REGULAR     = 0x00000040;
1003const auto NTM_BOLD        = 0x00000020;
1004const auto NTM_ITALIC      = 0x00000001;
1005
1006/* new in NT 5.0 */
1007
1008const auto NTM_NONNEGATIVE_AC  = 0x00010000;
1009const auto NTM_PS_OPENTYPE     = 0x00020000;
1010const auto NTM_TT_OPENTYPE     = 0x00040000;
1011const auto NTM_MULTIPLEMASTER  = 0x00080000;
1012const auto NTM_TYPE1           = 0x00100000;
1013const auto NTM_DSIG            = 0x00200000;
1014
1015align(4) struct NEWTEXTMETRICA {
1016	LONG        tmHeight;
1017	LONG        tmAscent;
1018	LONG        tmDescent;
1019	LONG        tmInternalLeading;
1020	LONG        tmExternalLeading;
1021	LONG        tmAveCharWidth;
1022	LONG        tmMaxCharWidth;
1023	LONG        tmWeight;
1024	LONG        tmOverhang;
1025	LONG        tmDigitizedAspectX;
1026	LONG        tmDigitizedAspectY;
1027	BYTE        tmFirstChar;
1028	BYTE        tmLastChar;
1029	BYTE        tmDefaultChar;
1030	BYTE        tmBreakChar;
1031	BYTE        tmItalic;
1032	BYTE        tmUnderlined;
1033	BYTE        tmStruckOut;
1034	BYTE        tmPitchAndFamily;
1035	BYTE        tmCharSet;
1036	DWORD   ntmFlags;
1037	UINT    ntmSizeEM;
1038	UINT    ntmCellHeight;
1039	UINT    ntmAvgWidth;
1040}
1041
1042typedef NEWTEXTMETRICA* PNEWTEXTMETRICA;
1043typedef NEWTEXTMETRICA* NPNEWTEXTMETRICA;
1044typedef NEWTEXTMETRICA* LPNEWTEXTMETRICA;
1045
1046struct NEWTEXTMETRICW {
1047	LONG        tmHeight;
1048	LONG        tmAscent;
1049	LONG        tmDescent;
1050	LONG        tmInternalLeading;
1051	LONG        tmExternalLeading;
1052	LONG        tmAveCharWidth;
1053	LONG        tmMaxCharWidth;
1054	LONG        tmWeight;
1055	LONG        tmOverhang;
1056	LONG        tmDigitizedAspectX;
1057	LONG        tmDigitizedAspectY;
1058	WCHAR       tmFirstChar;
1059	WCHAR       tmLastChar;
1060	WCHAR       tmDefaultChar;
1061	WCHAR       tmBreakChar;
1062	BYTE        tmItalic;
1063	BYTE        tmUnderlined;
1064	BYTE        tmStruckOut;
1065	BYTE        tmPitchAndFamily;
1066	BYTE        tmCharSet;
1067	DWORD   ntmFlags;
1068	UINT    ntmSizeEM;
1069	UINT    ntmCellHeight;
1070	UINT    ntmAvgWidth;
1071}
1072
1073typedef NEWTEXTMETRICW* PNEWTEXTMETRICW;
1074typedef NEWTEXTMETRICW* NPNEWTEXTMETRICW;
1075typedef NEWTEXTMETRICW* LPNEWTEXTMETRICW;
1076
1077version(UNICODE) {
1078	typedef NEWTEXTMETRICW NEWTEXTMETRIC;
1079	typedef PNEWTEXTMETRICW PNEWTEXTMETRIC;
1080	typedef NPNEWTEXTMETRICW NPNEWTEXTMETRIC;
1081	typedef LPNEWTEXTMETRICW LPNEWTEXTMETRIC;
1082}
1083else {
1084	typedef NEWTEXTMETRICA NEWTEXTMETRIC;
1085	typedef PNEWTEXTMETRICA PNEWTEXTMETRIC;
1086	typedef NPNEWTEXTMETRICA NPNEWTEXTMETRIC;
1087	typedef LPNEWTEXTMETRICA LPNEWTEXTMETRIC;
1088}
1089
1090struct NEWTEXTMETRICEXA {
1091    NEWTEXTMETRICA  ntmTm;
1092    FONTSIGNATURE   ntmFontSig;
1093}
1094
1095struct NEWTEXTMETRICEXW {
1096    NEWTEXTMETRICW  ntmTm;
1097    FONTSIGNATURE   ntmFontSig;
1098}
1099
1100version(UNICODE) {
1101	typedef NEWTEXTMETRICEXW NEWTEXTMETRICEX;
1102}
1103else {
1104	typedef NEWTEXTMETRICEXA NEWTEXTMETRICEX;
1105}
1106
1107/* GDI Logical Objects: */
1108
1109/* Pel Array */
1110struct PELARRAY {
1111    LONG        paXCount;
1112    LONG        paYCount;
1113    LONG        paXExt;
1114    LONG        paYExt;
1115    BYTE        paRGBs;
1116}
1117
1118typedef PELARRAY* PPELARRAY;
1119typedef PELARRAY* NPPELARRAY;
1120typedef PELARRAY* LPPELARRAY;
1121
1122/* Logical Brush (or Pattern) */
1123struct LOGBRUSH {
1124    UINT        lbStyle;
1125    COLORREF    lbColor;
1126    ULONG_PTR    lbHatch;    // Sundown: lbHatch could hold a HANDLE
1127} 
1128
1129typedef LOGBRUSH* PLOGBRUSH;
1130typedef LOGBRUSH* NPLOGBRUSH;
1131typedef LOGBRUSH* LPLOGBRUSH;
1132
1133struct LOGBRUSH32 {
1134	UINT        lbStyle;
1135	COLORREF    lbColor;
1136	ULONG       lbHatch;
1137}
1138
1139typedef LOGBRUSH32* PLOGBRUSH32;
1140typedef LOGBRUSH32* NPLOGBRUSH32;
1141typedef LOGBRUSH32* LPLOGBRUSH32;
1142
1143typedef LOGBRUSH            PATTERN;
1144typedef PATTERN             *PPATTERN;
1145typedef PATTERN *NPPATTERN;
1146typedef PATTERN *LPPATTERN;
1147
1148/* Logical Pen */
1149struct LOGPEN {
1150	UINT        lopnStyle;
1151	POINT       lopnWidth;
1152	COLORREF    lopnColor;
1153}
1154
1155typedef LOGPEN* PLOGPEN;
1156typedef LOGPEN* NPLOGPEN;
1157typedef LOGPEN* LPLOGPEN;
1158
1159struct EXTLOGPEN {
1160	DWORD       elpPenStyle;
1161	DWORD       elpWidth;
1162	UINT        elpBrushStyle;
1163	COLORREF    elpColor;
1164	ULONG_PTR   elpHatch;     //Sundown: elpHatch could take a HANDLE
1165	DWORD       elpNumEntries;
1166	DWORD[1]    elpStyleEntry;
1167}
1168
1169typedef EXTLOGPEN* PEXTLOGPEN;
1170typedef EXTLOGPEN* NPEXTLOGPEN;
1171typedef EXTLOGPEN* LPEXTLOGPEN;
1172
1173struct PALETTEENTRY {
1174	BYTE        peRed;
1175	BYTE        peGreen;
1176	BYTE        peBlue;
1177	BYTE        peFlags;
1178}
1179
1180typedef PALETTEENTRY* PPALETTEENTRY;
1181typedef PALETTEENTRY* LPPALETTEENTRY;
1182
1183/* Logical Palette */
1184struct LOGPALETTE {
1185    WORD        palVersion;
1186    WORD        palNumEntries;
1187	PALETTEENTRY[1]        palPalEntry;
1188}
1189
1190typedef LOGPALETTE* PLOGPALETTE;
1191typedef LOGPALETTE* NPLOGPALETTE;
1192typedef LOGPALETTE* LPLOGPALETTE;
1193
1194/* Logical Font */
1195const auto LF_FACESIZE         = 32;
1196
1197struct LOGFONTA {
1198	LONG      lfHeight;
1199	LONG      lfWidth;
1200	LONG      lfEscapement;
1201	LONG      lfOrientation;
1202	LONG      lfWeight;
1203	BYTE      lfItalic;
1204	BYTE      lfUnderline;
1205	BYTE      lfStrikeOut;
1206	BYTE      lfCharSet;
1207	BYTE      lfOutPrecision;
1208	BYTE      lfClipPrecision;
1209	BYTE      lfQuality;
1210	BYTE      lfPitchAndFamily;
1211	CHAR      lfFaceName[LF_FACESIZE];
1212}
1213
1214typedef LOGFONTA* PLOGFONTA;
1215typedef LOGFONTA* NPLOGFONTA;
1216typedef LOGFONTA* LPLOGFONTA;
1217
1218struct LOGFONTW {
1219	LONG      lfHeight;
1220	LONG      lfWidth;
1221	LONG      lfEscapement;
1222	LONG      lfOrientation;
1223	LONG      lfWeight;
1224	BYTE      lfItalic;
1225	BYTE      lfUnderline;
1226	BYTE      lfStrikeOut;
1227	BYTE      lfCharSet;
1228	BYTE      lfOutPrecision;
1229	BYTE      lfClipPrecision;
1230	BYTE      lfQuality;
1231	BYTE      lfPitchAndFamily;
1232	WCHAR     lfFaceName[LF_FACESIZE];
1233}
1234
1235typedef LOGFONTW* PLOGFONTW;
1236typedef LOGFONTW* NPLOGFONTW;
1237typedef LOGFONTW* LPLOGFONTW;
1238
1239version(UNICODE) {
1240	typedef LOGFONTW LOGFONT;
1241	typedef PLOGFONTW PLOGFONT;
1242	typedef NPLOGFONTW NPLOGFONT;
1243	typedef LPLOGFONTW LPLOGFONT;
1244}
1245else {
1246	typedef LOGFONTA LOGFONT;
1247	typedef PLOGFONTA PLOGFONT;
1248	typedef NPLOGFONTA NPLOGFONT;
1249	typedef LPLOGFONTA LPLOGFONT;
1250}
1251
1252const auto LF_FULLFACESIZE     = 64;
1253
1254/* Structure passed to FONTENUMPROC */
1255struct ENUMLOGFONTA {
1256    LOGFONTA elfLogFont;
1257    BYTE     elfFullName[LF_FULLFACESIZE];
1258    BYTE     elfStyle[LF_FACESIZE];
1259}
1260
1261typedef ENUMLOGFONTA* LPENUMLOGFONTA;
1262
1263/* Structure passed to FONTENUMPROC */
1264struct ENUMLOGFONTW {
1265    LOGFONTW elfLogFont;
1266    WCHAR[LF_FULLFACESIZE]    elfFullName;
1267    WCHAR[LF_FACESIZE]    elfStyle;
1268}
1269
1270typedef ENUMLOGFONTW* LPENUMLOGFONTW;
1271
1272version(UNICODE) {
1273	typedef ENUMLOGFONTW ENUMLOGFONT;
1274	typedef LPENUMLOGFONTW LPENUMLOGFONT;
1275}
1276else {
1277	typedef ENUMLOGFONTA ENUMLOGFONT;
1278	typedef LPENUMLOGFONTA LPENUMLOGFONT;
1279}
1280
1281struct ENUMLOGFONTEXA {
1282    LOGFONTA    elfLogFont;
1283    BYTE        elfFullName[LF_FULLFACESIZE];
1284    BYTE        elfStyle[LF_FACESIZE];
1285    BYTE        elfScript[LF_FACESIZE];
1286}
1287
1288typedef ENUMLOGFONTEXA* LPENUMLOGFONTEXA;
1289
1290struct ENUMLOGFONTEXW {
1291    LOGFONTW    elfLogFont;
1292    WCHAR[LF_FULLFACESIZE]       elfFullName;
1293    WCHAR[LF_FACESIZE]       elfStyle;
1294    WCHAR[LF_FACESIZE]       elfScript;
1295}
1296
1297typedef ENUMLOGFONTEXW* LPENUMLOGFONTEXW;
1298
1299version(UNICODE) {
1300	typedef ENUMLOGFONTEXW ENUMLOGFONTEX;
1301	typedef LPENUMLOGFONTEXW LPENUMLOGFONTEX;
1302}
1303else {
1304	typedef ENUMLOGFONTEXA ENUMLOGFONTEX;
1305	typedef LPENUMLOGFONTEXA LPENUMLOGFONTEX;
1306}
1307
1308const auto OUT_DEFAULT_PRECIS          = 0;
1309const auto OUT_STRING_PRECIS           = 1;
1310const auto OUT_CHARACTER_PRECIS        = 2;
1311const auto OUT_STROKE_PRECIS           = 3;
1312const auto OUT_TT_PRECIS               = 4;
1313const auto OUT_DEVICE_PRECIS           = 5;
1314const auto OUT_RASTER_PRECIS           = 6;
1315const auto OUT_TT_ONLY_PRECIS          = 7;
1316const auto OUT_OUTLINE_PRECIS          = 8;
1317const auto OUT_SCREEN_OUTLINE_PRECIS   = 9;
1318const auto OUT_PS_ONLY_PRECIS          = 10;
1319
1320const auto CLIP_DEFAULT_PRECIS     = 0;
1321const auto CLIP_CHARACTER_PRECIS   = 1;
1322const auto CLIP_STROKE_PRECIS      = 2;
1323const auto CLIP_MASK               = 0xf;
1324const auto CLIP_LH_ANGLES          = (1<<4);
1325const auto CLIP_TT_ALWAYS          = (2<<4);
1326
1327const auto CLIP_DFA_DISABLE        = (4<<4);
1328
1329const auto CLIP_EMBEDDED           = (8<<4);
1330
1331const auto DEFAULT_QUALITY         = 0;
1332const auto DRAFT_QUALITY           = 1;
1333const auto PROOF_QUALITY           = 2;
1334
1335const auto NONANTIALIASED_QUALITY  = 3;
1336const auto ANTIALIASED_QUALITY     = 4;
1337
1338const auto CLEARTYPE_QUALITY         = 5;
1339const auto CLEARTYPE_NATURAL_QUALITY       = 6;
1340
1341const auto DEFAULT_PITCH           = 0;
1342const auto FIXED_PITCH             = 1;
1343const auto VARIABLE_PITCH          = 2;
1344
1345const auto MONO_FONT               = 8;
1346
1347const auto ANSI_CHARSET            = 0;
1348const auto DEFAULT_CHARSET         = 1;
1349const auto SYMBOL_CHARSET          = 2;
1350const auto SHIFTJIS_CHARSET        = 128;
1351const auto HANGEUL_CHARSET         = 129;
1352const auto HANGUL_CHARSET          = 129;
1353const auto GB2312_CHARSET          = 134;
1354const auto CHINESEBIG5_CHARSET     = 136;
1355const auto OEM_CHARSET             = 255;
1356
1357const auto JOHAB_CHARSET           = 130;
1358const auto HEBREW_CHARSET          = 177;
1359const auto ARABIC_CHARSET          = 178;
1360const auto GREEK_CHARSET           = 161;
1361const auto TURKISH_CHARSET         = 162;
1362const auto VIETNAMESE_CHARSET      = 163;
1363const auto THAI_CHARSET            = 222;
1364const auto EASTEUROPE_CHARSET      = 238;
1365const auto RUSSIAN_CHARSET         = 204;
1366
1367const auto MAC_CHARSET             = 77;
1368const auto BALTIC_CHARSET          = 186;
1369
1370const auto FS_LATIN1               = 0x00000001;
1371const auto FS_LATIN2               = 0x00000002;
1372const auto FS_CYRILLIC             = 0x00000004;
1373const auto FS_GREEK                = 0x00000008;
1374const auto FS_TURKISH              = 0x00000010;
1375const auto FS_HEBREW               = 0x00000020;
1376const auto FS_ARABIC               = 0x00000040;
1377const auto FS_BALTIC               = 0x00000080;
1378const auto FS_VIETNAMESE           = 0x00000100;
1379const auto FS_THAI                 = 0x00010000;
1380const auto FS_JISJAPAN             = 0x00020000;
1381const auto FS_CHINESESIMP          = 0x00040000;
1382const auto FS_WANSUNG              = 0x00080000;
1383const auto FS_CHINESETRAD          = 0x00100000;
1384const auto FS_JOHAB                = 0x00200000;
1385const auto FS_SYMBOL               = 0x80000000;
1386
1387/* Font Families */
1388const auto FF_DONTCARE         = (0<<4);  /* Don't care or don't know. */
1389const auto FF_ROMAN            = (1<<4);  /* Variable stroke width, serifed. */
1390                                    /* Times Roman, Century Schoolbook, etc. */
1391const auto FF_SWISS            = (2<<4);  /* Variable stroke width, sans-serifed. */
1392                                    /* Helvetica, Swiss, etc. */
1393const auto FF_MODERN           = (3<<4);  /* Constant stroke width, serifed or sans-serifed. */
1394                                    /* Pica, Elite, Courier, etc. */
1395const auto FF_SCRIPT           = (4<<4);  /* Cursive, etc. */
1396const auto FF_DECORATIVE       = (5<<4);  /* Old English, etc. */
1397
1398/* Font Weights */
1399const auto FW_DONTCARE         = 0;
1400const auto FW_THIN             = 100;
1401const auto FW_EXTRALIGHT       = 200;
1402const auto FW_LIGHT            = 300;
1403const auto FW_NORMAL           = 400;
1404const auto FW_MEDIUM           = 500;
1405const auto FW_SEMIBOLD         = 600;
1406const auto FW_BOLD             = 700;
1407const auto FW_EXTRABOLD        = 800;
1408const auto FW_HEAVY            = 900;
1409
1410const auto FW_ULTRALIGHT       = FW_EXTRALIGHT;
1411const auto FW_REGULAR          = FW_NORMAL;
1412const auto FW_DEMIBOLD         = FW_SEMIBOLD;
1413const auto FW_ULTRABOLD        = FW_EXTRABOLD;
1414const auto FW_BLACK            = FW_HEAVY;
1415
1416const auto PANOSE_COUNT               = 10;
1417const auto PAN_FAMILYTYPE_INDEX        = 0;
1418const auto PAN_SERIFSTYLE_INDEX        = 1;
1419const auto PAN_WEIGHT_INDEX            = 2;
1420const auto PAN_PROPORTION_INDEX        = 3;
1421const auto PAN_CONTRAST_INDEX          = 4;
1422const auto PAN_STROKEVARIATION_INDEX   = 5;
1423const auto PAN_ARMSTYLE_INDEX          = 6;
1424const auto PAN_LETTERFORM_INDEX        = 7;
1425const auto PAN_MIDLINE_INDEX           = 8;
1426const auto PAN_XHEIGHT_INDEX           = 9;
1427
1428const auto PAN_CULTURE_LATIN           = 0;
1429
1430struct PANOSE {
1431	BYTE    bFamilyType;
1432	BYTE    bSerifStyle;
1433	BYTE    bWeight;
1434	BYTE    bProportion;
1435	BYTE    bContrast;
1436	BYTE    bStrokeVariation;
1437	BYTE    bArmStyle;
1438	BYTE    bLetterform;
1439	BYTE    bMidline;
1440	BYTE    bXHeight;
1441}
1442
1443typedef PANOSE* LPPANOSE;
1444
1445const auto PAN_ANY                         = 0; /* Any                            */
1446const auto PAN_NO_FIT                      = 1; /* No Fit                         */
1447
1448const auto PAN_FAMILY_TEXT_DISPLAY         = 2; /* Text and Display               */
1449const auto PAN_FAMILY_SCRIPT               = 3; /* Script                         */
1450const auto PAN_FAMILY_DECORATIVE           = 4; /* Decorative                     */
1451const auto PAN_FAMILY_PICTORIAL            = 5; /* Pictorial                      */
1452
1453const auto PAN_SERIF_COVE                  = 2; /* Cove                           */
1454const auto PAN_SERIF_OBTUSE_COVE           = 3; /* Obtuse Cove                    */
1455const auto PAN_SERIF_SQUARE_COVE           = 4; /* Square Cove                    */
1456const auto PAN_SERIF_OBTUSE_SQUARE_COVE    = 5; /* Obtuse Square Cove             */
1457const auto PAN_SERIF_SQUARE                = 6; /* Square                         */
1458const auto PAN_SERIF_THIN                  = 7; /* Thin                           */
1459const auto PAN_SERIF_BONE                  = 8; /* Bone                           */
1460const auto PAN_SERIF_EXAGGERATED           = 9; /* Exaggerated                    */
1461const auto PAN_SERIF_TRIANGLE             = 10; /* Triangle                       */
1462const auto PAN_SERIF_NORMAL_SANS          = 11; /* Normal Sans                    */
1463const auto PAN_SERIF_OBTUSE_SANS          = 12; /* Obtuse Sans                    */
1464const auto PAN_SERIF_PERP_SANS            = 13; /* Prep Sans                      */
1465const auto PAN_SERIF_FLARED               = 14; /* Flared                         */
1466const auto PAN_SERIF_ROUNDED              = 15; /* Rounded                        */
1467
1468const auto PAN_WEIGHT_VERY_LIGHT           = 2; /* Very Light                     */
1469const auto PAN_WEIGHT_LIGHT                = 3; /* Light                          */
1470const auto PAN_WEIGHT_THIN                 = 4; /* Thin                           */
1471const auto PAN_WEIGHT_BOOK                 = 5; /* Book                           */
1472const auto PAN_WEIGHT_MEDIUM               = 6; /* Medium                         */
1473const auto PAN_WEIGHT_DEMI                 = 7; /* Demi                           */
1474const auto PAN_WEIGHT_BOLD                 = 8; /* Bold                           */
1475const auto PAN_WEIGHT_HEAVY                = 9; /* Heavy                          */
1476const auto PAN_WEIGHT_BLACK               = 10; /* Black                          */
1477const auto PAN_WEIGHT_NORD                = 11; /* Nord                           */
1478
1479const auto PAN_PROP_OLD_STYLE              = 2; /* Old Style                      */
1480const auto PAN_PROP_MODERN                 = 3; /* Modern                         */
1481const auto PAN_PROP_EVEN_WIDTH             = 4; /* Even Width                     */
1482const auto PAN_PROP_EXPANDED               = 5; /* Expanded                       */
1483const auto PAN_PROP_CONDENSED              = 6; /* Condensed                      */
1484const auto PAN_PROP_VERY_EXPANDED          = 7; /* Very Expanded                  */
1485const auto PAN_PROP_VERY_CONDENSED         = 8; /* Very Condensed                 */
1486const auto PAN_PROP_MONOSPACED             = 9; /* Monospaced                     */
1487
1488const auto PAN_CONTRAST_NONE               = 2; /* None                           */
1489const auto PAN_CONTRAST_VERY_LOW           = 3; /* Very Low                       */
1490const auto PAN_CONTRAST_LOW                = 4; /* Low                            */
1491const auto PAN_CONTRAST_MEDIUM_LOW         = 5; /* Medium Low                     */
1492const auto PAN_CONTRAST_MEDIUM             = 6; /* Medium                         */
1493const auto PAN_CONTRAST_MEDIUM_HIGH        = 7; /* Mediim High                    */
1494const auto PAN_CONTRAST_HIGH               = 8; /* High                           */
1495const auto PAN_CONTRAST_VERY_HIGH          = 9; /* Very High                      */
1496
1497const auto PAN_STROKE_GRADUAL_DIAG         = 2; /* Gradual/Diagonal               */
1498const auto PAN_STROKE_GRADUAL_TRAN         = 3; /* Gradual/Transitional           */
1499const auto PAN_STROKE_GRADUAL_VERT         = 4; /* Gradual/Vertical               */
1500const auto PAN_STROKE_GRADUAL_HORZ         = 5; /* Gradual/Horizontal             */
1501const auto PAN_STROKE_RAPID_VERT           = 6; /* Rapid/Vertical                 */
1502const auto PAN_STROKE_RAPID_HORZ           = 7; /* Rapid/Horizontal               */
1503const auto PAN_STROKE_INSTANT_VERT         = 8; /* Instant/Vertical               */
1504
1505const auto PAN_STRAIGHT_ARMS_HORZ          = 2; /* Straight Arms/Horizontal       */
1506const auto PAN_STRAIGHT_ARMS_WEDGE         = 3; /* Straight Arms/Wedge            */
1507const auto PAN_STRAIGHT_ARMS_VERT          = 4; /* Straight Arms/Vertical         */
1508const auto PAN_STRAIGHT_ARMS_SINGLE_SERIF  = 5; /* Straight Arms/Single-Serif     */
1509const auto PAN_STRAIGHT_ARMS_DOUBLE_SERIF  = 6; /* Straight Arms/Double-Serif     */
1510const auto PAN_BENT_ARMS_HORZ              = 7; /* Non-Straight Arms/Horizontal   */
1511const auto PAN_BENT_ARMS_WEDGE             = 8; /* Non-Straight Arms/Wedge        */
1512const auto PAN_BENT_ARMS_VERT              = 9; /* Non-Straight Arms/Vertical     */
1513const auto PAN_BENT_ARMS_SINGLE_SERIF     = 10; /* Non-Straight Arms/Single-Serif */
1514const auto PAN_BENT_ARMS_DOUBLE_SERIF     = 11; /* Non-Straight Arms/Double-Serif */
1515
1516const auto PAN_LETT_NORMAL_CONTACT         = 2; /* Normal/Contact                 */
1517const auto PAN_LETT_NORMAL_WEIGHTED        = 3; /* Normal/Weighted                */
1518const auto PAN_LETT_NORMAL_BOXED           = 4; /* Normal/Boxed                   */
1519const auto PAN_LETT_NORMAL_FLATTENED       = 5; /* Normal/Flattened               */
1520const auto PAN_LETT_NORMAL_ROUNDED         = 6; /* Normal/Rounded                 */
1521const auto PAN_LETT_NORMAL_OFF_CENTER      = 7; /* Normal/Off Center              */
1522const auto PAN_LETT_NORMAL_SQUARE          = 8; /* Normal/Square                  */
1523const auto PAN_LETT_OBLIQUE_CONTACT        = 9; /* Oblique/Contact                */
1524const auto PAN_LETT_OBLIQUE_WEIGHTED      = 10; /* Oblique/Weighted               */
1525const auto PAN_LETT_OBLIQUE_BOXED         = 11; /* Oblique/Boxed                  */
1526const auto PAN_LETT_OBLIQUE_FLATTENED     = 12; /* Oblique/Flattened              */
1527const auto PAN_LETT_OBLIQUE_ROUNDED       = 13; /* Oblique/Rounded                */
1528const auto PAN_LETT_OBLIQUE_OFF_CENTER    = 14; /* Oblique/Off Center             */
1529const auto PAN_LETT_OBLIQUE_SQUARE        = 15; /* Oblique/Square                 */
1530
1531const auto PAN_MIDLINE_STANDARD_TRIMMED    = 2; /* Standard/Trimmed               */
1532const auto PAN_MIDLINE_STANDARD_POINTED    = 3; /* Standard/Pointed               */
1533const auto PAN_MIDLINE_STANDARD_SERIFED    = 4; /* Standard/Serifed               */
1534const auto PAN_MIDLINE_HIGH_TRIMMED        = 5; /* High/Trimmed                   */
1535const auto PAN_MIDLINE_HIGH_POINTED        = 6; /* High/Pointed                   */
1536const auto PAN_MIDLINE_HIGH_SERIFED        = 7; /* High/Serifed                   */
1537const auto PAN_MIDLINE_CONSTANT_TRIMMED    = 8; /* Constant/Trimmed               */
1538const auto PAN_MIDLINE_CONSTANT_POINTED    = 9; /* Constant/Pointed               */
1539const auto PAN_MIDLINE_CONSTANT_SERIFED   = 10; /* Constant/Serifed               */
1540const auto PAN_MIDLINE_LOW_TRIMMED        = 11; /* Low/Trimmed                    */
1541const auto PAN_MIDLINE_LOW_POINTED        = 12; /* Low/Pointed                    */
1542const auto PAN_MIDLINE_LOW_SERIFED        = 13; /* Low/Serifed                    */
1543
1544const auto PAN_XHEIGHT_CONSTANT_SMALL      = 2; /* Constant/Small                 */
1545const auto PAN_XHEIGHT_CONSTANT_STD        = 3; /* Constant/Standard              */
1546const auto PAN_XHEIGHT_CONSTANT_LARGE      = 4; /* Constant/Large                 */
1547const auto PAN_XHEIGHT_DUCKING_SMALL       = 5; /* Ducking/Small                  */
1548const auto PAN_XHEIGHT_DUCKING_STD         = 6; /* Ducking/Standard               */
1549const auto PAN_XHEIGHT_DUCKING_LARGE       = 7; /* Ducking/Large                  */
1550
1551
1552const auto ELF_VENDOR_SIZE     = 4;
1553
1554/* The extended logical font       */
1555/* An extension of the ENUMLOGFONT */
1556
1557struct EXTLOGFONTA {
1558    LOGFONTA    elfLogFont;
1559    BYTE        elfFullName[LF_FULLFACESIZE];
1560    BYTE        elfStyle[LF_FACESIZE];
1561    DWORD       elfVersion;     /* 0 for the first release of NT */
1562    DWORD       elfStyleSize;
1563    DWORD       elfMatch;
1564    DWORD       elfReserved;
1565    BYTE        elfVendorId[ELF_VENDOR_SIZE];
1566    DWORD       elfCulture;     /* 0 for Latin                   */
1567    PANOSE      elfPanose;
1568}
1569
1570typedef EXTLOGFONTA* PEXTLOGFONTA;
1571typedef EXTLOGFONTA* NPEXTLOGFONTA;
1572typedef EXTLOGFONTA* LPEXTLOGFONTA;
1573
1574struct EXTLOGFONTW {
1575    LOGFONTW    elfLogFont;
1576    WCHAR       elfFullName[LF_FULLFACESIZE];
1577    WCHAR       elfStyle[LF_FACESIZE];
1578    DWORD       elfVersion;     /* 0 for the first release of NT */
1579    DWORD       elfStyleSize;
1580    DWORD       elfMatch;
1581    DWORD       elfReserved;
1582    BYTE        elfVendorId[ELF_VENDOR_SIZE];
1583    DWORD       elfCulture;     /* 0 for Latin                   */
1584    PANOSE      elfPanose;
1585}
1586
1587typedef EXTLOGFONTW* PEXTLOGFONTW;
1588typedef EXTLOGFONTW* NPEXTLOGFONTW;
1589typedef EXTLOGFONTW* LPEXTLOGFONTW;
1590
1591version(UNICODE) {
1592	typedef EXTLOGFONTW EXTLOGFONT;
1593	typedef PEXTLOGFONTW PEXTLOGFONT;
1594	typedef NPEXTLOGFONTW NPEXTLOGFONT;
1595	typedef LPEXTLOGFONTW LPEXTLOGFONT;
1596}
1597else {
1598	typedef EXTLOGFONTA EXTLOGFONT;
1599	typedef PEXTLOGFONTA PEXTLOGFONT;
1600	typedef NPEXTLOGFONTA NPEXTLOGFONT;
1601	typedef LPEXTLOGFONTA LPEXTLOGFONT;
1602}
1603
1604const auto ELF_VERSION         = 0;
1605const auto ELF_CULTURE_LATIN   = 0;
1606
1607/* EnumFonts Masks */
1608const auto RASTER_FONTTYPE     = 0x0001;
1609const auto DEVICE_FONTTYPE     = 0x002;
1610const auto TRUETYPE_FONTTYPE   = 0x004;
1611
1612template RGB(BYTE r, BYTE g, BYTE b) {
1613	const COLORREF RGB = (cast(COLORREF)((cast(BYTE)(r)|(cast(WORD)(cast(BYTE)(g))<<8))|((cast(DWORD)cast(BYTE)(b))<<16)));
1614}
1615
1616template PALETTERGB(BYTE r, BYTE g, BYTE b) {
1617	const uint PALETTERGB = (0x2000000 | RGB!(r,g,b));
1618}
1619
1620template PALETTEINDEX(BYTE i) {
1621	const uint PALETTEINDEX = (cast(COLORREF)(0x01000000 | cast(DWORD)cast(WORD)(i)));
1622}
1623
1624/* palette entry flags */
1625
1626const auto PC_RESERVED     = 0x01;    /* palette index used for animation */
1627const auto PC_EXPLICIT     = 0x02;    /* palette index is explicit to device */
1628const auto PC_NOCOLLAPSE   = 0x04;    /* do not match color to system palette */
1629
1630BYTE GetRValue(COLORREF rgb) {
1631	return LOBYTE(cast(WORD)rgb);
1632}
1633
1634BYTE GetGValue(COLORREF rgb) {
1635	return LOBYTE(cast(WORD)((cast(WORD)rgb) >> 8));
1636}
1637
1638BYTE GetBValue(COLORREF rgb) {
1639	return LOBYTE(cast(WORD)(rgb >> 16));
1640}
1641
1642/* Background Modes */
1643const auto TRANSPARENT         = 1;
1644const auto OPAQUE              = 2;
1645const auto BKMODE_LAST         = 2;
1646
1647/* Graphics Modes */
1648
1649const auto GM_COMPATIBLE       = 1;
1650const auto GM_ADVANCED         = 2;
1651const auto GM_LAST             = 2;
1652
1653/* PolyDraw and GetPath point types */
1654const auto PT_CLOSEFIGURE      = 0x01;
1655const auto PT_LINETO           = 0x02;
1656const auto PT_BEZIERTO         = 0x04;
1657const auto PT_MOVETO           = 0x06;
1658
1659/* Mapping Modes */
1660const auto MM_TEXT             = 1;
1661const auto MM_LOMETRIC         = 2;
1662const auto MM_HIMETRIC         = 3;
1663const auto MM_LOENGLISH        = 4;
1664const auto MM_HIENGLISH        = 5;
1665const auto MM_TWIPS            = 6;
1666const auto MM_ISOTROPIC        = 7;
1667const auto MM_ANISOTROPIC      = 8;
1668
1669/* Min and Max Mapping Mode values */
1670const auto MM_MIN              = MM_TEXT;
1671const auto MM_MAX              = MM_ANISOTROPIC;
1672const auto MM_MAX_FIXEDSCALE   = MM_TWIPS;
1673
1674/* Coordinate Modes */
1675const auto ABSOLUTE            = 1;
1676const auto RELATIVE            = 2;
1677
1678/* Stock Logical Objects */
1679const auto WHITE_BRUSH         = 0;
1680const auto LTGRAY_BRUSH        = 1;
1681const auto GRAY_BRUSH          = 2;
1682const auto DKGRAY_BRUSH        = 3;
1683const auto BLACK_BRUSH         = 4;
1684const auto NULL_BRUSH          = 5;
1685const auto HOLLOW_BRUSH        = NULL_BRUSH;
1686const auto WHITE_PEN           = 6;
1687const auto BLACK_PEN           = 7;
1688const auto NULL_PEN            = 8;
1689const auto OEM_FIXED_FONT      = 10;
1690const auto ANSI_FIXED_FONT     = 11;
1691const auto ANSI_VAR_FONT       = 12;
1692const auto SYSTEM_FONT         = 13;
1693const auto DEVICE_DEFAULT_FONT = 14;
1694const auto DEFAULT_PALETTE     = 15;
1695const auto SYSTEM_FIXED_FONT   = 16;
1696
1697const auto DEFAULT_GUI_FONT    = 17;
1698
1699const auto DC_BRUSH            = 18;
1700const auto DC_PEN              = 19;
1701
1702const auto STOCK_LAST          = 19;
1703
1704const auto CLR_INVALID     = 0xFFFFFFFF;
1705
1706/* Brush Styles */
1707const auto BS_SOLID            = 0;
1708const auto BS_NULL             = 1;
1709const auto BS_HOLLOW           = BS_NULL;
1710const auto BS_HATCHED          = 2;
1711const auto BS_PATTERN          = 3;
1712const auto BS_INDEXED          = 4;
1713const auto BS_DIBPATTERN       = 5;
1714const auto BS_DIBPATTERNPT     = 6;
1715const auto BS_PATTERN8X8       = 7;
1716const auto BS_DIBPATTERN8X8    = 8;
1717const auto BS_MONOPATTERN      = 9;
1718
1719/* Hatch Styles */
1720const auto HS_HORIZONTAL       = 0;       /* ----- */
1721const auto HS_VERTICAL         = 1;       /* ||||| */
1722const auto HS_FDIAGONAL        = 2;       /* \\\\\ */
1723const auto HS_BDIAGONAL        = 3;       /* ///// */
1724const auto HS_CROSS            = 4;       /* +++++ */
1725const auto HS_DIAGCROSS        = 5;       /* xxxxx */
1726
1727/* Pen Styles */
1728const auto PS_SOLID            = 0;
1729const auto PS_DASH             = 1;       /* -------  */
1730const auto PS_DOT              = 2;       /* .......  */
1731const auto PS_DASHDOT          = 3;       /* _._._._  */
1732const auto PS_DASHDOTDOT       = 4;       /* _.._.._  */
1733const auto PS_NULL             = 5;
1734const auto PS_INSIDEFRAME      = 6;
1735const auto PS_USERSTYLE        = 7;
1736const auto PS_ALTERNATE        = 8;
1737const auto PS_STYLE_MASK       = 0x0000000F;
1738
1739const auto PS_ENDCAP_ROUND     = 0x00000000;
1740const auto PS_ENDCAP_SQUARE    = 0x00000100;
1741const auto PS_ENDCAP_FLAT      = 0x00000200;
1742const auto PS_ENDCAP_MASK      = 0x00000F00;
1743
1744const auto PS_JOIN_ROUND       = 0x00000000;
1745const auto PS_JOIN_BEVEL       = 0x00001000;
1746const auto PS_JOIN_MITER       = 0x00002000;
1747const auto PS_JOIN_MASK        = 0x0000F000;
1748
1749const auto PS_COSMETIC         = 0x00000000;
1750const auto PS_GEOMETRIC        = 0x00010000;
1751const auto PS_TYPE_MASK        = 0x000F0000;
1752
1753const auto AD_COUNTERCLOCKWISE = 1;
1754const auto AD_CLOCKWISE        = 2;
1755
1756/* Device Parameters for GetDeviceCaps() */
1757const auto DRIVERVERSION = 0;     /* Device driver version                    */
1758const auto TECHNOLOGY    = 2;     /* Device classification                    */
1759const auto HORZSIZE      = 4;     /* Horizontal size in millimeters           */
1760const auto VERTSIZE      = 6;     /* Vertical size in millimeters             */
1761const auto HORZRES       = 8;     /* Horizontal width in pixels               */
1762const auto VERTRES       = 10;    /* Vertical height in pixels                */
1763const auto BITSPIXEL     = 12;    /* Number of bits per pixel                 */
1764const auto PLANES        = 14;    /* Number of planes                         */
1765const auto NUMBRUSHES    = 16;    /* Number of brushes the device has         */
1766const auto NUMPENS       = 18;    /* Number of pens the device has            */
1767const auto NUMMARKERS    = 20;    /* Number of markers the device has         */
1768const auto NUMFONTS      = 22;    /* Number of fonts the device has           */
1769const auto NUMCOLORS     = 24;    /* Number of colors the device supports     */
1770const auto PDEVICESIZE   = 26;    /* Size required for device descriptor      */
1771const auto CURVECAPS     = 28;    /* Curve capabilities                       */
1772const auto LINECAPS      = 30;    /* Line capabilities                        */
1773const auto POLYGONALCAPS = 32;    /* Polygonal capabilities                   */
1774const auto TEXTCAPS      = 34;    /* Text capabilities                        */
1775const auto CLIPCAPS      = 36;    /* Clipping capabilities                    */
1776const auto RASTERCAPS    = 38;    /* Bitblt capabilities                      */
1777const auto ASPECTX       = 40;    /* Length of the X leg                      */
1778const auto ASPECTY       = 42;    /* Length of the Y leg                      */
1779const auto ASPECTXY      = 44;    /* Length of the hypotenuse                 */
1780
1781const auto LOGPIXELSX    = 88;    /* Logical pixels/inch in X                 */
1782const auto LOGPIXELSY    = 90;    /* Logical pixels/inch in Y                 */
1783
1784const auto SIZEPALETTE  = 104;    /* Number of entries in physical palette    */
1785const auto NUMRESERVED  = 106;    /* Number of reserved entries in palette    */
1786const auto COLORRES     = 108;    /* Actual color resolution                  */
1787
1788// Printing related DeviceCaps. These replace the appropriate Escapes
1789
1790const auto PHYSICALWIDTH   = 110; /* Physical Width in device units           */
1791const auto PHYSICALHEIGHT  = 111; /* Physical Height in device units          */
1792const auto PHYSICALOFFSETX = 112; /* Physical Printable Area x margin         */
1793const auto PHYSICALOFFSETY = 113; /* Physical Printable Area y margin         */
1794const auto SCALINGFACTORX  = 114; /* Scaling factor x                         */
1795const auto SCALINGFACTORY  = 115; /* Scaling factor y                         */
1796
1797// Display driver specific
1798
1799const auto VREFRESH        = 116;  /* Current vertical refresh rate of the    */
1800                             /* display device (for displays only) in Hz*/
1801const auto DESKTOPVERTRES  = 117;  /* Horizontal width of entire desktop in   */
1802                             /* pixels                                  */
1803const auto DESKTOPHORZRES  = 118;  /* Vertical height of entire desktop in    */
1804                             /* pixels                                  */
1805const auto BLTALIGNMENT    = 119;  /* Preferred blt alignment                 */
1806
1807const auto SHADEBLENDCAPS  = 120;  /* Shading and blending caps               */
1808const auto COLORMGMTCAPS   = 121;  /* Color Management caps                   */
1809
1810/* Device Capability Masks: */
1811
1812/* Device Technologies */
1813const auto DT_PLOTTER          = 0;   /* Vector plotter                   */
1814const auto DT_RASDISPLAY       = 1;   /* Raster display                   */
1815const auto DT_RASPRINTER       = 2;   /* Raster printer                   */
1816const auto DT_RASCAMERA        = 3;   /* Raster camera                    */
1817const auto DT_CHARSTREAM       = 4;   /* Character-stream, PLP            */
1818const auto DT_METAFILE         = 5;   /* Metafile, VDM                    */
1819const auto DT_DISPFILE         = 6;   /* Display-file                     */
1820
1821/* Curve Capabilities */
1822const auto CC_NONE             = 0;   /* Curves not supported             */
1823const auto CC_CIRCLES          = 1;   /* Can do circles                   */
1824const auto CC_PIE              = 2;   /* Can do pie wedges                */
1825const auto CC_CHORD            = 4;   /* Can do chord arcs                */
1826const auto CC_ELLIPSES         = 8;   /* Can do ellipese                  */
1827const auto CC_WIDE             = 16;  /* Can do wide lines                */
1828const auto CC_STYLED           = 32;  /* Can do styled lines              */
1829const auto CC_WIDESTYLED       = 64;  /* Can do wide styled lines         */
1830const auto CC_INTERIORS        = 128; /* Can do interiors                 */
1831const auto CC_ROUNDRECT        = 256; /*                                  */
1832
1833/* Line Capabilities */
1834const auto LC_NONE             = 0;   /* Lines not supported              */
1835const auto LC_POLYLINE         = 2;   /* Can do polylines                 */
1836const auto LC_MARKER           = 4;   /* Can do markers                   */
1837const auto LC_POLYMARKER       = 8;   /* Can do polymarkers               */
1838const auto LC_WIDE             = 16;  /* Can do wide lines                */
1839const auto LC_STYLED           = 32;  /* Can do styled lines              */
1840const auto LC_WIDESTYLED       = 64;  /* Can do wide styled lines         */
1841const auto LC_INTERIORS        = 128; /* Can do interiors                 */
1842
1843/* Polygonal Capabilities */
1844const auto PC_NONE             = 0;   /* Polygonals not supported         */
1845const auto PC_POLYGON          = 1;   /* Can do polygons                  */
1846const auto PC_RECTANGLE        = 2;   /* Can do rectangles                */
1847const auto PC_WINDPOLYGON      = 4;   /* Can do winding polygons          */
1848const auto PC_TRAPEZOID        = 4;   /* Can do trapezoids                */
1849const auto PC_SCANLINE         = 8;   /* Can do scanlines                 */
1850const auto PC_WIDE             = 16;  /* Can do wide borders              */
1851const auto PC_STYLED           = 32;  /* Can do styled borders            */
1852const auto PC_WIDESTYLED       = 64;  /* Can do wide styled borders       */
1853const auto PC_INTERIORS        = 128; /* Can do interiors                 */
1854const auto PC_POLYPOLYGON      = 256; /* Can do polypolygons              */
1855const auto PC_PATHS            = 512; /* Can do paths                     */
1856
1857/* Clipping Capabilities */
1858const auto CP_NONE             = 0;   /* No clipping of output            */
1859const auto CP_RECTANGLE        = 1;   /* Output clipped to rects          */
1860const auto CP_REGION           = 2;   /* obsolete                         */
1861
1862/* Text Capabilities */
1863const auto TC_OP_CHARACTER     = 0x00000001;  /* Can do OutputPrecision   CHARACTER      */
1864const auto TC_OP_STROKE        = 0x00000002;  /* Can do OutputPrecision   STROKE         */
1865const auto TC_CP_STROKE        = 0x00000004;  /* Can do ClipPrecision     STROKE         */
1866const auto TC_CR_90            = 0x00000008;  /* Can do CharRotAbility    90             */
1867const auto TC_CR_ANY           = 0x00000010;  /* Can do CharRotAbility    ANY            */
1868const auto TC_SF_X_YINDEP      = 0x00000020;  /* Can do ScaleFreedom      X_YINDEPENDENT */
1869const auto TC_SA_DOUBLE        = 0x00000040;  /* Can do ScaleAbility      DOUBLE         */
1870const auto TC_SA_INTEGER       = 0x00000080;  /* Can do ScaleAbility      INTEGER        */
1871const auto TC_SA_CONTIN        = 0x00000100;  /* Can do ScaleAbility      CONTINUOUS     */
1872const auto TC_EA_DOUBLE        = 0x00000200;  /* Can do EmboldenAbility   DOUBLE         */
1873const auto TC_IA_ABLE          = 0x00000400;  /* Can do ItalisizeAbility  ABLE           */
1874const auto TC_UA_ABLE          = 0x00000800;  /* Can do UnderlineAbility  ABLE           */
1875const auto TC_SO_ABLE          = 0x00001000;  /* Can do StrikeOutAbility  ABLE           */
1876const auto TC_RA_ABLE          = 0x00002000;  /* Can do RasterFontAble    ABLE           */
1877const auto TC_VA_ABLE          = 0x00004000;  /* Can do VectorFontAble    ABLE           */
1878const auto TC_RESERVED         = 0x00008000;
1879const auto TC_SCROLLBLT        = 0x00010000;  /* Don't do text scroll with blt           */
1880
1881/* Raster Capabilities */
1882const auto RC_NONE = 0;
1883const auto RC_BITBLT           = 1;       /* Can do standard BLT.             */
1884const auto RC_BANDING          = 2;       /* Device requires banding support  */
1885const auto RC_SCALING          = 4;       /* Device requires scaling support  */
1886const auto RC_BITMAP64         = 8;       /* Device can support >64K bitmap   */
1887const auto RC_GDI20_OUTPUT     = 0x0010;      /* has 2.0 output calls         */
1888const auto RC_GDI20_STATE      = 0x0020;
1889const auto RC_SAVEBITMAP       = 0x0040;
1890const auto RC_DI_BITMAP        = 0x0080;      /* supports DIB to memory       */
1891const auto RC_PALETTE          = 0x0100;      /* supports a palette           */
1892const auto RC_DIBTODEV         = 0x0200;      /* supports DIBitsToDevice      */
1893const auto RC_BIGFONT          = 0x0400;      /* supports >64K fonts          */
1894const auto RC_STRETCHBLT       = 0x0800;      /* supports StretchBlt          */
1895const auto RC_FLOODFILL        = 0x1000;      /* supports FloodFill           */
1896const auto RC_STRETCHDIB       = 0x2000;      /* supports StretchDIBits       */
1897const auto RC_OP_DX_OUTPUT     = 0x4000;
1898const auto RC_DEVBITS          = 0x8000;
1899
1900/* Shading and blending caps */
1901const auto SB_NONE             = 0x00000000;
1902const auto SB_CONST_ALPHA      = 0x00000001;
1903const auto SB_PIXEL_ALPHA      = 0x00000002;
1904const auto SB_PREMULT_ALPHA    = 0x00000004;
1905
1906const auto SB_GRAD_RECT        = 0x00000010;
1907const auto SB_GRAD_TRI         = 0x00000020;
1908
1909/* Color Management caps */
1910const auto CM_NONE             = 0x00000000;
1911const auto CM_DEVICE_ICM       = 0x00000001;
1912const auto CM_GAMMA_RAMP       = 0x00000002;
1913const auto CM_CMYK_COLOR       = 0x00000004;
1914
1915/* DIB color table identifiers */
1916
1917const auto DIB_RGB_COLORS      = 0; /* color table in RGBs */
1918const auto DIB_PAL_COLORS      = 1; /* color table in palette indices */
1919
1920/* constants for Get/SetSystemPaletteUse() */
1921
1922const auto SYSPAL_ERROR    		= 0;
1923const auto SYSPAL_STATIC   		= 1;
1924const auto SYSPAL_NOSTATIC 		= 2;
1925const auto SYSPAL_NOSTATIC256	= 3;
1926
1927/* constants for CreateDIBitmap */
1928const auto CBM_INIT        = 0x04;   /* initialize bitmap */
1929
1930/* ExtFloodFill style flags */
1931const auto  FLOODFILLBORDER   = 0;
1932const auto  FLOODFILLSURFACE  = 1;
1933
1934/* size of a device name string */
1935// import winuser.d:
1936//const auto CCHDEVICENAME = 32;
1937
1938/* size of a form name string */
1939const auto CCHFORMNAME = 32;
1940
1941struct DEVMODEA {
1942    BYTE[CCHDEVICENAME]   dmDeviceName;
1943    WORD dmSpecVersion;
1944    WORD dmDriverVersion;
1945    WORD dmSize;
1946    WORD dmDriverExtra;
1947    DWORD dmFields;
1948    union _inner_union {
1949      /* printer only fields */
1950      struct _dm_printer {
1951        short dmOrientation;
1952        short dmPaperSize;
1953        short dmPaperLength;
1954        short dmPaperWidth;
1955        short dmScale;
1956        short dmCopies;
1957        short dmDefaultSource;
1958        short dmPrintQuality;
1959      }
1960      /* display only fields */
1961      struct _dm_display {
1962        POINTL dmPosition;
1963        DWORD  dmDisplayOrientation;
1964        DWORD  dmDisplayFixedOutput;
1965      }
1966      
1967      _dm_printer printer;
1968      _dm_display display;
1969    }
1970    _inner_union fields;
1971    short dmColor;
1972    short dmDuplex;
1973    short dmYResolution;
1974    short dmTTOption;
1975    short dmCollate;
1976    BYTE   dmFormName[CCHFORMNAME];
1977    WORD   dmLogPixels;
1978    DWORD  dmBitsPerPel;
1979    DWORD  dmPelsWidth;
1980    DWORD  dmPelsHeight;
1981    DWORD  dmDisplayFlags;
1982    DWORD  dmDisplayFrequency;
1983    DWORD  dmICMMethod;
1984    DWORD  dmICMIntent;
1985    DWORD  dmMediaType;
1986    DWORD  dmDitherType;
1987    DWORD  dmReserved1;
1988    DWORD  dmReserved2;
1989    DWORD  dmPanningWidth;
1990    DWORD  dmPanningHeight;
1991}
1992
1993typedef DEVMODEA* PDEVMODEA;
1994typedef DEVMODEA* NPDEVMODEA;
1995typedef DEVMODEA* LPDEVMODEA;
1996
1997struct DEVMODEW {
1998    WCHAR[CCHDEVICENAME]  dmDeviceName;
1999    WORD dmSpecVersion;
2000    WORD dmDriverVersion;
2001    WORD dmSize;
2002    WORD dmDriverExtra;
2003    DWORD dmFields;
2004
2005	union _inner_union {
2006      /* printer only fields */
2007      struct _dm_printer {
2008        short dmOrientation;
2009        short dmPaperSize;
2010        short dmPaperLength;
2011        short dmPaperWidth;
2012        short dmScale;
2013        short dmCopies;
2014        short dmDefaultSource;
2015        short dmPrintQuality;
2016      }
2017
2018      /* display only fields */
2019      struct _dm_display {
2020        POINTL dmPosition;
2021        DWORD  dmDisplayOrientation;
2022        DWORD  dmDisplayFixedOutput;
2023      }
2024
2025      _dm_printer printer;
2026      _dm_display display;
2027    }
2028
2029    _inner_union fields;
2030    short dmColor;
2031    short dmDuplex;
2032    short dmYResolution;
2033    short dmTTOption;
2034    short dmCollate;
2035    WCHAR  dmFormName[CCHFORMNAME];
2036    WORD   dmLogPixels;
2037    DWORD  dmBitsPerPel;
2038    DWORD  dmPelsWidth;
2039    DWORD  dmPelsHeight;
2040    DWORD  dmDisplayFlags;
2041    DWORD  dmDisplayFrequency;
2042
2043    DWORD  dmICMMethod;
2044    DWORD  dmICMIntent;
2045    DWORD  dmMediaType;
2046    DWORD  dmDitherType;
2047    DWORD  dmReserved1;
2048    DWORD  dmReserved2;
2049    DWORD  dmPanningWidth;
2050    DWORD  dmPanningHeight;
2051}
2052
2053typedef DEVMODEW* PDEVMODEW;
2054typedef DEVMODEW* NPDEVMODEW;
2055typedef DEVMODEW* LPDEVMODEW;
2056
2057version(UNICODE) {
2058	typedef DEVMODEW DEVMODE;
2059	typedef PDEVMODEW PDEVMODE;
2060	typedef NPDEVMODEW NPDEVMODE;
2061	typedef LPDEVMODEW LPDEVMODE;
2062}
2063else {
2064	typedef DEVMODEA DEVMODE;
2065	typedef PDEVMODEA PDEVMODE;
2066	typedef NPDEVMODEA NPDEVMODE;
2067	typedef LPDEVMODEA LPDEVMODE;
2068}
2069
2070/* current version of specification */
2071const auto DM_SPECVERSION = 0x0401;
2072
2073/* field selection bits */
2074const auto DM_ORIENTATION          = 0x00000001L;
2075const auto DM_PAPERSIZE            = 0x00000002L;
2076const auto DM_PAPERLENGTH          = 0x00000004L;
2077const auto DM_PAPERWIDTH           = 0x00000008L;
2078const auto DM_SCALE                = 0x00000010L;
2079
2080const auto DM_POSITION             = 0x00000020L;
2081const auto DM_NUP                  = 0x00000040L;
2082
2083const auto DM_DISPLAYORIENTATION   = 0x00000080L;
2084
2085const auto DM_COPIES               = 0x00000100L;
2086const auto DM_DEFAULTSOURCE        = 0x00000200L;
2087const auto DM_PRINTQUALITY         = 0x00000400L;
2088const auto DM_COLOR                = 0x00000800L;
2089const auto DM_DUPLEX               = 0x00001000L;
2090const auto DM_YRESOLUTION          = 0x00002000L;
2091const auto DM_TTOPTION             = 0x00004000L;
2092const auto DM_COLLATE              = 0x00008000L;
2093const auto DM_FORMNAME             = 0x00010000L;
2094const auto DM_LOGPIXELS            = 0x00020000L;
2095const auto DM_BITSPERPEL           = 0x00040000L;
2096const auto DM_PELSWIDTH            = 0x00080000L;
2097const auto DM_PELSHEIGHT           = 0x00100000L;
2098const auto DM_DISPLAYFLAGS         = 0x00200000L;
2099const auto DM_DISPLAYFREQUENCY     = 0x00400000L;
2100
2101const auto DM_ICMMETHOD            = 0x00800000L;
2102const auto DM_ICMINTENT            = 0x01000000L;
2103const auto DM_MEDIATYPE            = 0x02000000L;
2104const auto DM_DITHERTYPE           = 0x04000000L;
2105const auto DM_PANNINGWIDTH         = 0x08000000L;
2106const auto DM_PANNINGHEIGHT        = 0x10000000L;
2107
2108const auto DM_DISPLAYFIXEDOUTPUT   = 0x20000000L;
2109
2110/* orientation selections */
2111const auto DMORIENT_PORTRAIT   = 1;
2112const auto DMORIENT_LANDSCAPE  = 2;
2113
2114/* paper selections */
2115const auto DMPAPER_LETTER               = 1;  /* Letter 8 1/2 x 11 in               */
2116const auto DMPAPER_FIRST                = DMPAPER_LETTER;
2117const auto DMPAPER_LETTERSMALL          = 2;  /* Letter Small 8 1/2 x 11 in         */
2118const auto DMPAPER_TABLOID              = 3;  /* Tabloid 11 x 17 in                 */
2119const auto DMPAPER_LEDGER               = 4;  /* Ledger 17 x 11 in                  */
2120const auto DMPAPER_LEGAL                = 5;  /* Legal 8 1/2 x 14 in                */
2121const auto DMPAPER_STATEMENT            = 6;  /* Statement 5 1/2 x 8 1/2 in         */
2122const auto DMPAPER_EXECUTIVE            = 7;  /* Executive 7 1/4 x 10 1/2 in        */
2123const auto DMPAPER_A3                   = 8;  /* A3 297 x 420 mm                    */
2124const auto DMPAPER_A4                   = 9;  /* A4 210 x 297 mm                    */
2125const auto DMPAPER_A4SMALL             = 10;  /* A4 Small 210 x 297 mm              */
2126const auto DMPAPER_A5                  = 11;  /* A5 148 x 210 mm                    */
2127const auto DMPAPER_B4                  = 12;  /* B4 (JIS) 250 x 354                 */
2128const auto DMPAPER_B5                  = 13;  /* B5 (JIS) 182 x 257 mm              */
2129const auto DMPAPER_FOLIO               = 14;  /* Folio 8 1/2 x 13 in                */
2130const auto DMPAPER_QUARTO              = 15;  /* Quarto 215 x 275 mm                */
2131const auto DMPAPER_10X14               = 16;  /* 10x14 in                           */
2132const auto DMPAPER_11X17               = 17;  /* 11x17 in                           */
2133const auto DMPAPER_NOTE                = 18;  /* Note 8 1/2 x 11 in                 */
2134const auto DMPAPER_ENV_9               = 19;  /* Envelope #9 3 7/8 x 8 7/8          */
2135const auto DMPAPER_ENV_10              = 20;  /* Envelope #10 4 1/8 x 9 1/2         */
2136const auto DMPAPER_ENV_11              = 21;  /* Envelope #11 4 1/2 x 10 3/8        */
2137const auto DMPAPER_ENV_12              = 22;  /* Envelope #12 4 \276 x 11           */
2138const auto DMPAPER_ENV_14              = 23;  /* Envelope #14 5 x 11 1/2            */
2139const auto DMPAPER_CSHEET              = 24;  /* C size sheet                       */
2140const auto DMPAPER_DSHEET              = 25;  /* D size sheet                       */
2141const auto DMPAPER_ESHEET              = 26;  /* E size sheet                       */
2142const auto DMPAPER_ENV_DL              = 27;  /* Envelope DL 110 x 220mm            */
2143const auto DMPAPER_ENV_C5              = 28;  /* Envelope C5 162 x 229 mm           */
2144const auto DMPAPER_ENV_C3              = 29;  /* Envelope C3  324 x 458 mm          */
2145const auto DMPAPER_ENV_C4              = 30;  /* Envelope C4  229 x 324 mm          */
2146const auto DMPAPER_ENV_C6              = 31;  /* Envelope C6  114 x 162 mm          */
2147const auto DMPAPER_ENV_C65             = 32;  /* Envelope C65 114 x 229 mm          */
2148const auto DMPAPER_ENV_B4              = 33;  /* Envelope B4  250 x 353 mm          */
2149const auto DMPAPER_ENV_B5              = 34;  /* Envelope B5  176 x 250 mm          */
2150const auto DMPAPER_ENV_B6              = 35;  /* Envelope B6  176 x 125 mm          */
2151const auto DMPAPER_ENV_ITALY           = 36;  /* Envelope 110 x 230 mm              */
2152const auto DMPAPER_ENV_MONARCH         = 37;  /* Envelope Monarch 3.875 x 7.5 in    */
2153const auto DMPAPER_ENV_PERSONAL        = 38;  /* 6 3/4 Envelope 3 5/8 x 6 1/2 in    */
2154const auto DMPAPER_FANFOLD_US          = 39;  /* US Std Fanfold 14 7/8 x 11 in      */
2155const auto DMPAPER_FANFOLD_STD_GERMAN  = 40;  /* German Std Fanfold 8 1/2 x 12 in   */
2156const auto DMPAPER_FANFOLD_LGL_GERMAN  = 41;  /* German Legal Fanfold 8 1/2 x 13 in */
2157
2158const auto DMPAPER_ISO_B4              = 42;  /* B4 (ISO) 250 x 353 mm              */
2159const auto DMPAPER_JAPANESE_POSTCARD   = 43;  /* Japanese Postcard 100 x 148 mm     */
2160const auto DMPAPER_9X11                = 44;  /* 9 x 11 in                          */
2161const auto DMPAPER_10X11               = 45;  /* 10 x 11 in                         */
2162const auto DMPAPER_15X11               = 46;  /* 15 x 11 in                         */
2163const auto DMPAPER_ENV_INVITE          = 47;  /* Envelope Invite 220 x 220 mm       */
2164const auto DMPAPER_RESERVED_48         = 48;  /* RESERVED--DO NOT USE               */
2165const auto DMPAPER_RESERVED_49         = 49;  /* RESERVED--DO NOT USE               */
2166const auto DMPAPER_LETTER_EXTRA        = 50;  /* Letter Extra 9 \275 x 12 in        */
2167const auto DMPAPER_LEGAL_EXTRA         = 51;  /* Legal Extra 9 \275 x 15 in         */
2168const auto DMPAPER_TABLOID_EXTRA       = 52;  /* Tabloid Extra 11.69 x 18 in        */
2169const auto DMPAPER_A4_EXTRA            = 53;  /* A4 Extra 9.27 x 12.69 in           */
2170const auto DMPAPER_LETTER_TRANSVERSE   = 54;  /* Letter Transverse 8 \275 x 11 in   */
2171const auto DMPAPER_A4_TRANSVERSE       = 55;  /* A4 Transverse 210 x 297 mm         */
2172const auto DMPAPER_LETTER_EXTRA_TRANSVERSE = 56; /* Letter Extra Transverse 9\275 x 12 in */
2173const auto DMPAPER_A_PLUS              = 57;  /* SuperA/SuperA/A4 227 x 356 mm      */
2174const auto DMPAPER_B_PLUS              = 58;  /* SuperB/SuperB/A3 305 x 487 mm      */
2175const auto DMPAPER_LETTER_PLUS         = 59;  /* Letter Plus 8.5 x 12.69 in         */
2176const auto DMPAPER_A4_PLUS             = 60;  /* A4 Plus 210 x 330 mm               */
2177const auto DMPAPER_A5_TRANSVERSE       = 61;  /* A5 Transverse 148 x 210 mm         */
2178const auto DMPAPER_B5_TRANSVERSE       = 62;  /* B5 (JIS) Transverse 182 x 257 mm   */
2179const auto DMPAPER_A3_EXTRA            = 63;  /* A3 Extra 322 x 445 mm              */
2180const auto DMPAPER_A5_EXTRA            = 64;  /* A5 Extra 174 x 235 mm              */
2181const auto DMPAPER_B5_EXTRA            = 65;  /* B5 (ISO) Extra 201 x 276 mm        */
2182const auto DMPAPER_A2                  = 66;  /* A2 420 x 594 mm                    */
2183const auto DMPAPER_A3_TRANSVERSE       = 67;  /* A3 Transverse 297 x 420 mm         */
2184const auto DMPAPER_A3_EXTRA_TRANSVERSE = 68;  /* A3 Extra Transverse 322 x 445 mm   */
2185
2186const auto DMPAPER_DBL_JAPANESE_POSTCARD = 69; /* Japanese Double Postcard 200 x 148 mm */
2187const auto DMPAPER_A6                  = 70;  /* A6 105 x 148 mm                 */
2188const auto DMPAPER_JENV_KAKU2          = 71;  /* Japanese Envelope Kaku #2       */
2189const auto DMPAPER_JENV_KAKU3          = 72;  /* Japanese Envelope Kaku #3       */
2190const auto DMPAPER_JENV_CHOU3          = 73;  /* Japanese Envelope Chou #3       */
2191const auto DMPAPER_JENV_CHOU4          = 74;  /* Japanese Envelope Chou #4       */
2192const auto DMPAPER_LETTER_ROTATED      = 75;  /* Letter Rotated 11 x 8 1/2 11 in */
2193const auto DMPAPER_A3_ROTATED          = 76;  /* A3 Rotated 420 x 297 mm         */
2194const auto DMPAPER_A4_ROTATED          = 77;  /* A4 Rotated 297 x 210 mm         */
2195const auto DMPAPER_A5_ROTATED          = 78;  /* A5 Rotated 210 x 148 mm         */
2196const auto DMPAPER_B4_JIS_ROTATED      = 79;  /* B4 (JIS) Rotated 364 x 257 mm   */
2197const auto DMPAPER_B5_JIS_ROTATED      = 80;  /* B5 (JIS) Rotated 257 x 182 mm   */
2198const auto DMPAPER_JAPANESE_POSTCARD_ROTATED = 81; /* Japanese Postcard Rotated 148 x 100 mm */
2199const auto DMPAPER_DBL_JAPANESE_POSTCARD_ROTATED = 82; /* Double Japanese Postcard Rotated 148 x 200 mm */
2200const auto DMPAPER_A6_ROTATED          = 83;  /* A6 Rotated 148 x 105 mm         */
2201const auto DMPAPER_JENV_KAKU2_ROTATED  = 84;  /* Japanese Envelope Kaku #2 Rotated */
2202const auto DMPAPER_JENV_KAKU3_ROTATED  = 85;  /* Japanese Envelope Kaku #3 Rotated */
2203const auto DMPAPER_JENV_CHOU3_ROTATED  = 86;  /* Japanese Envelope Chou #3 Rotated */
2204const auto DMPAPER_JENV_CHOU4_ROTATED  = 87;  /* Japanese Envelope Chou #4 Rotated */
2205const auto DMPAPER_B6_JIS              = 88;  /* B6 (JIS) 128 x 182 mm           */
2206const auto DMPAPER_B6_JIS_ROTATED      = 89;  /* B6 (JIS) Rotated 182 x 128 mm   */
2207const auto DMPAPER_12X11               = 90;  /* 12 x 11 in                      */
2208const auto DMPAPER_JENV_YOU4           = 91;  /* Japanese Envelope You #4        */
2209const auto DMPAPER_JENV_YOU4_ROTATED   = 92;  /* Japanese Envelope You #4 Rotated*/
2210const auto DMPAPER_P16K                = 93;  /* PRC 16K 146 x 215 mm            */
2211const auto DMPAPER_P32K                = 94;  /* PRC 32K 97 x 151 mm             */
2212const auto DMPAPER_P32KBIG             = 95;  /* PRC 32K(Big) 97 x 151 mm        */
2213const auto DMPAPER_PENV_1              = 96;  /* PRC Envelope #1 102 x 165 mm    */
2214const auto DMPAPER_PENV_2              = 97;  /* PRC Envelope #2 102 x 176 mm    */
2215const auto DMPAPER_PENV_3              = 98;  /* PRC Envelope #3 125 x 176 mm    */
2216const auto DMPAPER_PENV_4              = 99;  /* PRC Envelope #4 110 x 208 mm    */
2217const auto DMPAPER_PENV_5              = 100; /* PRC Envelope #5 110 x 220 mm    */
2218const auto DMPAPER_PENV_6              = 101; /* PRC Envelope #6 120 x 230 mm    */
2219const auto DMPAPER_PENV_7              = 102; /* PRC Envelope #7 160 x 230 mm    */
2220const auto DMPAPER_PENV_8              = 103; /* PRC Envelope #8 120 x 309 mm    */
2221const auto DMPAPER_PENV_9              = 104; /* PRC Envelope #9 229 x 324 mm    */
2222const auto DMPAPER_PENV_10             = 105; /* PRC Envelope #10 324 x 458 mm   */
2223const auto DMPAPER_P16K_ROTATED        = 106; /* PRC 16K Rotated                 */
2224const auto DMPAPER_P32K_ROTATED        = 107; /* PRC 32K Rotated                 */
2225const auto DMPAPER_P32KBIG_ROTATED     = 108; /* PRC 32K(Big) Rotated            */
2226const auto DMPAPER_PENV_1_ROTATED      = 109; /* PRC Envelope #1 Rotated 165 x 102 mm */
2227const auto DMPAPER_PENV_2_ROTATED      = 110; /* PRC Envelope #2 Rotated 176 x 102 mm */
2228const auto DMPAPER_PENV_3_ROTATED      = 111; /* PRC Envelope #3 Rotated 176 x 125 mm */
2229const auto DMPAPER_PENV_4_ROTATED      = 112; /* PRC Envelope #4 Rotated 208 x 110 mm */
2230const auto DMPAPER_PENV_5_ROTATED      = 113; /* PRC Envelope #5 Rotated 220 x 110 mm */
2231const auto DMPAPER_PENV_6_ROTATED      = 114; /* PRC Envelope #6 Rotated 230 x 120 mm */
2232const auto DMPAPER_PENV_7_ROTATED      = 115; /* PRC Envelope #7 Rotated 230 x 160 mm */
2233const auto DMPAPER_PENV_8_ROTATED      = 116; /* PRC Envelope #8 Rotated 309 x 120 mm */
2234const auto DMPAPER_PENV_9_ROTATED      = 117; /* PRC Envelope #9 Rotated 324 x 229 mm */
2235const auto DMPAPER_PENV_10_ROTATED     = 118; /* PRC Envelope #10 Rotated 458 x 324 mm */
2236
2237const auto DMPAPER_LAST                = DMPAPER_PENV_10_ROTATED;
2238
2239const auto DMPAPER_USER                = 256;
2240
2241/* bin selections */
2242const auto DMBIN_UPPER         = 1;
2243const auto DMBIN_FIRST         = DMBIN_UPPER;
2244const auto DMBIN_ONLYONE       = 1;
2245const auto DMBIN_LOWER         = 2;
2246const auto DMBIN_MIDDLE        = 3;
2247const auto DMBIN_MANUAL        = 4;
2248const auto DMBIN_ENVELOPE      = 5;
2249const auto DMBIN_ENVMANUAL     = 6;
2250const auto DMBIN_AUTO          = 7;
2251const auto DMBIN_TRACTOR       = 8;
2252const auto DMBIN_SMALLFMT      = 9;
2253const auto DMBIN_LARGEFMT      = 10;
2254const auto DMBIN_LARGECAPACITY = 11;
2255const auto DMBIN_CASSETTE      = 14;
2256const auto DMBIN_FORMSOURCE    = 15;
2257const auto DMBIN_LAST          = DMBIN_FORMSOURCE;
2258
2259const auto DMBIN_USER          = 256;     /* device specific bins start here */
2260
2261/* print qualities */
2262const auto DMRES_DRAFT         = (-1);
2263const auto DMRES_LOW           = (-2);
2264const auto DMRES_MEDIUM        = (-3);
2265const auto DMRES_HIGH          = (-4);
2266
2267/* color enable/disable for color printers */
2268const auto DMCOLOR_MONOCHROME  = 1;
2269const auto DMCOLOR_COLOR       = 2;
2270
2271/* duplex enable */
2272const auto DMDUP_SIMPLEX    = 1;
2273const auto DMDUP_VERTICAL   = 2;
2274const auto DMDUP_HORIZONTAL = 3;
2275
2276/* TrueType options */
2277const auto DMTT_BITMAP     = 1;       /* print TT fonts as graphics */
2278const auto DMTT_DOWNLOAD   = 2;       /* download TT fonts as soft fonts */
2279const auto DMTT_SUBDEV     = 3;       /* substitute device fonts for TT fonts */
2280
2281const auto DMTT_DOWNLOAD_OUTLINE = 4; /* download TT fonts as outline soft fonts */
2282
2283/* Collation selections */
2284const auto DMCOLLATE_FALSE  = 0;
2285const auto DMCOLLATE_TRUE   = 1;
2286
2287/* DEVMODE dmDisplayOrientation specifiations */
2288const auto DMDO_DEFAULT    = 0;
2289const auto DMDO_90         = 1;
2290const auto DMDO_180        = 2;
2291const auto DMDO_270        = 3;
2292
2293/* DEVMODE dmDisplayFixedOutput specifiations */
2294const auto DMDFO_DEFAULT   = 0;
2295const auto DMDFO_STRETCH   = 1;
2296const auto DMDFO_CENTER    = 2;
2297
2298/* DEVMODE dmDisplayFlags flags */
2299
2300// const auto DM_GRAYSCALE            0x00000001 /* This flag is no longer valid */
2301const auto DM_INTERLACED           = 0x00000002;
2302const auto DMDISPLAYFLAGS_TEXTMODE = 0x00000004;
2303
2304/* dmNup , multiple logical page per physical page options */
2305const auto DMNUP_SYSTEM        = 1;
2306const auto DMNUP_ONEUP         = 2;
2307
2308/* ICM methods */
2309const auto DMICMMETHOD_NONE    = 1;   /* ICM disabled */
2310const auto DMICMMETHOD_SYSTEM  = 2;   /* ICM handled by system */
2311const auto DMICMMETHOD_DRIVER  = 3;   /* ICM handled by driver */
2312const auto DMICMMETHOD_DEVICE  = 4;   /* ICM handled by device */
2313
2314const auto DMICMMETHOD_USER  = 256;   /* Device-specific methods start here */
2315
2316/* ICM Intents */
2317const auto DMICM_SATURATE          = 1;   /* Maximize color saturation */
2318const auto DMICM_CONTRAST          = 2;   /* Maximize color contrast */
2319const auto DMICM_COLORIMETRIC       = 3;   /* Use specific color metric */
2320const auto DMICM_ABS_COLORIMETRIC   = 4;   /* Use specific color metric */
2321
2322const auto DMICM_USER        = 256;   /* Device-specific intents start here */
2323
2324/* Media types */
2325
2326const auto DMMEDIA_STANDARD      = 1;   /* Standard paper */
2327const auto DMMEDIA_TRANSPARENCY  = 2;   /* Transparency */
2328const auto DMMEDIA_GLOSSY        = 3;   /* Glossy paper */
2329
2330const auto DMMEDIA_USER        = 256;   /* Device-specific media start here */
2331
2332/* Dither types */
2333const auto DMDITHER_NONE       = 1;      /* No dithering */
2334const auto DMDITHER_COARSE     = 2;      /* Dither with a coarse brush */
2335const auto DMDITHER_FINE       = 3;      /* Dither with a fine brush */
2336const auto DMDITHER_LINEART    = 4;      /* LineArt dithering */
2337const auto DMDITHER_ERRORDIFFUSION = 5;  /* LineArt dithering */
2338const auto DMDITHER_RESERVED6      = 6;      /* LineArt dithering */
2339const auto DMDITHER_RESERVED7      = 7;      /* LineArt dithering */
2340const auto DMDITHER_RESERVED8      = 8;      /* LineArt dithering */
2341const auto DMDITHER_RESERVED9      = 9;      /* LineArt dithering */
2342const auto DMDITHER_GRAYSCALE  = 10;     /* Device does grayscaling */
2343
2344const auto DMDITHER_USER     = 256;   /* Device-specific dithers start here */
2345
2346struct DISPLAY_DEVICEA {
2347    DWORD  cb;
2348    CHAR[32]   DeviceName;
2349    CHAR[128]   DeviceString;
2350    DWORD  StateFlags;
2351    CHAR[128]   DeviceID;
2352    CHAR[128]   DeviceKey;
2353}
2354
2355typedef DISPLAY_DEVICEA* PDISPLAY_DEVICEA;
2356typedef DISPLAY_DEVICEA* LPDISPLAY_DEVICEA;
2357
2358struct DISPLAY_DEVICEW {
2359    DWORD  cb;
2360    WCHAR[32]  DeviceName;
2361    WCHAR[128]  DeviceString;
2362    DWORD  StateFlags;
2363    WCHAR[128]  DeviceID;
2364    WCHAR[128]  DeviceKey;
2365} 
2366
2367typedef DISPLAY_DEVICEW* PDISPLAY_DEVICEW;
2368typedef DISPLAY_DEVICEW* LPDISPLAY_DEVICEW;
2369
2370version(UNICODE) {
2371	typedef DISPLAY_DEVICEW DISPLAY_DEVICE;
2372	typedef PDISPLAY_DEVICEW PDISPLAY_DEVICE;
2373	typedef LPDISPLAY_DEVICEW LPDISPLAY_DEVICE;
2374}
2375else {
2376	typedef DISPLAY_DEVICEA DISPLAY_DEVICE;
2377	typedef PDISPLAY_DEVICEA PDISPLAY_DEVICE;
2378	typedef LPDISPLAY_DEVICEA LPDISPLAY_DEVICE;
2379}
2380
2381const auto DISPLAY_DEVICE_ATTACHED_TO_DESKTOP = 0x00000001;
2382const auto DISPLAY_DEVICE_MULTI_DRIVER        = 0x00000002;
2383const auto DISPLAY_DEVICE_PRIMARY_DEVICE      = 0x00000004;
2384const auto DISPLAY_DEVICE_MIRRORING_DRIVER    = 0x00000008;
2385const auto DISPLAY_DEVICE_VGA_COMPATIBLE      = 0x00000010;
2386const auto DISPLAY_DEVICE_REMOVABLE           = 0x00000020;
2387const auto DISPLAY_DEVICE_MODESPRUNED         = 0x08000000;
2388const auto DISPLAY_DEVICE_REMOTE              = 0x04000000;
2389const auto DISPLAY_DEVICE_DISCONNECT          = 0x02000000;
2390const auto DISPLAY_DEVICE_TS_COMPATIBLE       = 0x00200000;
2391const auto DISPLAY_DEVICE_UNSAFE_MODES_ON     = 0x00080000;
2392
2393/* Child device state */
2394const auto DISPLAY_DEVICE_ACTIVE              = 0x00000001;
2395const auto DISPLAY_DEVICE_ATTACHED            = 0x00000002;
2396
2397/* GetRegionData/ExtCreateRegion */
2398
2399const auto RDH_RECTANGLES  = 1;
2400
2401struct RGNDATAHEADER {
2402	DWORD   dwSize;
2403	DWORD   iType;
2404	DWORD   nCount;
2405	DWORD   nRgnSize;
2406	RECT    rcBound;
2407}
2408
2409typedef RGNDATAHEADER* PRGNDATAHEADER;
2410
2411struct RGNDATA {
2412    RGNDATAHEADER   rdh;
2413    char[1]            Buffer;
2414}
2415
2416typedef RGNDATA* PRGNDATA;
2417typedef RGNDATA* LPRGNDATA;
2418typedef RGNDATA* NPRGNDATA;
2419
2420/* for GetRandomRgn */
2421const auto SYSRGN  = 4;
2422
2423struct ABC {
2424	int     abcA;
2425	UINT    abcB;
2426	int     abcC;
2427}
2428
2429typedef ABC* PABC;
2430typedef ABC* NPABC;
2431typedef ABC* LPABC;
2432
2433struct ABCFLOAT {
2434	FLOAT   abcfA;
2435	FLOAT   abcfB;
2436	FLOAT   abcfC;
2437}
2438
2439typedef ABCFLOAT* PABCFLOAT;
2440typedef ABCFLOAT* NPABCFLOAT;
2441typedef ABCFLOAT* LPABCFLOAT;
2442
2443align(4) struct OUTLINETEXTMETRICA {
2444    UINT    otmSize;
2445    TEXTMETRICA otmTextMetrics;
2446    BYTE    otmFiller;
2447    PANOSE  otmPanoseNumber;
2448    UINT    otmfsSelection;
2449    UINT    otmfsType;
2450     int    otmsCharSlopeRise;
2451     int    otmsCharSlopeRun;
2452     int    otmItalicAngle;
2453    UINT    otmEMSquare;
2454     int    otmAscent;
2455     int    otmDescent;
2456    UINT    otmLineGap;
2457    UINT    otmsCapEmHeight;
2458    UINT    otmsXHeight;
2459    RECT    otmrcFontBox;
2460     int    otmMacAscent;
2461     int    otmMacDescent;
2462    UINT    otmMacLineGap;
2463    UINT    otmusMinimumPPEM;
2464    POINT   otmptSubscriptSize;
2465    POINT   otmptSubscriptOffset;
2466    POINT   otmptSuperscriptSize;
2467    POINT   otmptSuperscriptOffset;
2468    UINT    otmsStrikeoutSize;
2469     int    otmsStrikeoutPosition;
2470     int    otmsUnderscoreSize;
2471     int    otmsUnderscorePosition;
2472    PSTR    otmpFamilyName;
2473    PSTR    otmpFaceName;
2474    PSTR    otmpStyleName;
2475    PSTR    otmpFullName;
2476}
2477
2478typedef OUTLINETEXTMETRICA* POUTLINETEXTMETRICA;
2479typedef OUTLINETEXTMETRICA* NPOUTLINETEXTMETRICA;
2480typedef OUTLINETEXTMETRICA* LPOUTLINETEXTMETRICA;
2481
2482align(4) struct OUTLINETEXTMETRICW {
2483    UINT    otmSize;
2484    TEXTMETRICW otmTextMetrics;
2485    BYTE    otmFiller;
2486    PANOSE  otmPanoseNumber;
2487    UINT    otmfsSelection;
2488    UINT    otmfsType;
2489     int    otmsCharSlopeRise;
2490     int    otmsCharSlopeRun;
2491     int    otmItalicAngle;
2492    UINT    otmEMSquare;
2493     int    otmAscent;
2494     int    otmDescent;
2495    UINT    otmLineGap;
2496    UINT    otmsCapEmHeight;
2497    UINT    otmsXHeight;
2498    RECT    otmrcFontBox;
2499     int    otmMacAscent;
2500     int    otmMacDescent;
2501    UINT    otmMacLineGap;
2502    UINT    otmusMinimumPPEM;
2503    POINT   otmptSubscriptSize;
2504    POINT   otmptSubscriptOffset;
2505    POINT   otmptSuperscriptSize;
2506    POINT   otmptSuperscriptOffset;
2507    UINT    otmsStrikeoutSize;
2508     int    otmsStrikeoutPosition;
2509     int    otmsUnderscoreSize;
2510     int    otmsUnderscorePosition;
2511    PSTR    otmpFamilyName;
2512    PSTR    otmpFaceName;
2513    PSTR    otmpStyleName;
2514    PSTR    otmpFullName;
2515}
2516
2517typedef OUTLINETEXTMETRICW* POUTLINETEXTMETRICW;
2518typedef OUTLINETEXTMETRICW* NPOUTLINETEXTMETRICW;
2519typedef OUTLINETEXTMETRICW* LPOUTLINETEXTMETRICW;
2520
2521version(UNICODE) {
2522	typedef OUTLINETEXTMETRICW OUTLINETEXTMETRIC;
2523	typedef POUTLINETEXTMETRICW POUTLINETEXTMETRIC;
2524	typedef NPOUTLINETEXTMETRICW NPOUTLINETEXTMETRIC;
2525	typedef LPOUTLINETEXTMETRICW LPOUTLINETEXTMETRIC;
2526}
2527else {
2528	typedef OUTLINETEXTMETRICA OUTLINETEXTMETRIC;
2529	typedef POUTLINETEXTMETRICA POUTLINETEXTMETRIC;
2530	typedef NPOUTLINETEXTMETRICA NPOUTLINETEXTMETRIC;
2531	typedef LPOUTLINETEXTMETRICA LPOUTLINETEXTMETRIC;
2532}
2533
2534struct POLYTEXTA {
2535    int       x;
2536    int       y;
2537    UINT      n;
2538    LPCSTR    lpstr;
2539    UINT      uiFlags;
2540    RECT      rcl;
2541    int      *pdx;
2542}
2543
2544typedef POLYTEXTA* PPOLYTEXTA;
2545typedef POLYTEXTA* NPPOLYTEXTA;
2546typedef POLYTEXTA* LPPOLYTEXTA;
2547
2548struct POLYTEXTW {
2549    int       x;
2550    int       y;
2551    UINT      n;
2552    LPCWSTR   lpstr;
2553    UINT      uiFlags;
2554    RECT      rcl;
2555    int      *pdx;
2556}
2557
2558typedef POLYTEXTW* PPOLYTEXTW;
2559typedef POLYTEXTW* NPPOLYTEXTW;
2560typedef POLYTEXTW* LPPOLYTEXTW;
2561
2562version(UNICODE) {
2563	typedef POLYTEXTW POLYTEXT;
2564	typedef PPOLYTEXTW PPOLYTEXT;
2565	typedef NPPOLYTEXTW NPPOLYTEXT;
2566	typedef LPPOLYTEXTW LPPOLYTEXT;
2567}
2568else {
2569	typedef POLYTEXTA POLYTEXT;
2570	typedef PPOLYTEXTA PPOLYTEXT;
2571	typedef NPPOLYTEXTA NPPOLYTEXT;
2572	typedef LPPOLYTEXTA LPPOLYTEXT;
2573}
2574
2575struct FIXED {
2576    short   value;
2577    WORD    fract;
2578}
2579
2580struct MAT2 {
2581	FIXED  eM11;
2582	FIXED  eM12;
2583	FIXED  eM21;
2584	FIXED  eM22;
2585}
2586
2587typedef MAT2* LPMAT2;
2588
2589struct GLYPHMETRICS {
2590    UINT    gmBlackBoxX;
2591    UINT    gmBlackBoxY;
2592    POINT   gmptGlyphOrigin;
2593    short   gmCellIncX;
2594    short   gmCellIncY;
2595}
2596
2597typedef GLYPHMETRICS* LPGLYPHMETRICS;
2598
2599//  GetGlyphOutline constants
2600
2601const auto GGO_METRICS        = 0;
2602const auto GGO_BITMAP         = 1;
2603const auto GGO_NATIVE         = 2;
2604const auto GGO_BEZIER         = 3;
2605
2606const auto  GGO_GRAY2_BITMAP   = 4;
2607const auto  GGO_GRAY4_BITMAP   = 5;
2608const auto  GGO_GRAY8_BITMAP   = 6;
2609const auto  GGO_GLYPH_INDEX    = 0x0080;
2610
2611const auto  GGO_UNHINTED       = 0x0100;
2612
2613const auto TT_POLYGON_TYPE   = 24;
2614
2615const auto TT_PRIM_LINE       = 1;
2616const auto TT_PRIM_QSPLINE    = 2;
2617const auto TT_PRIM_CSPLINE    = 3;
2618
2619struct POINTFX {
2620    FIXED x;
2621    FIXED y;
2622}
2623
2624typedef POINTFX* LPPOINTFX;
2625
2626struct TTPOLYCURVE {
2627    WORD    wType;
2628    WORD    cpfx;
2629    POINTFX[1] apfx;
2630}
2631
2632typedef TTPOLYCURVE* LPTTPOLYCURVE;
2633
2634struct TTPOLYGONHEADER {
2635    DWORD   cb;
2636    DWORD   dwType;
2637    POINTFX pfxStart;
2638}
2639
2640typedef TTPOLYGONHEADER* LPTTPOLYGONHEADER;
2641
2642const auto GCP_DBCS           = 0x0001;
2643const auto GCP_REORDER        = 0x0002;
2644const auto GCP_USEKERNING     = 0x0008;
2645const auto GCP_GLYPHSHAPE     = 0x0010;
2646const auto GCP_LIGATE         = 0x0020;
2647////const auto GCP_GLYPHINDEXING  0x0080
2648const auto GCP_DIACRITIC      = 0x0100;
2649const auto GCP_KASHIDA        = 0x0400;
2650const auto GCP_ERROR          = 0x8000;
2651const auto FLI_MASK           = 0x103B;
2652
2653const auto GCP_JUSTIFY        = 0x00010000;
2654////const auto GCP_NODIACRITICS   0x00020000L
2655const auto FLI_GLYPHS         = 0x00040000L;
2656const auto GCP_CLASSIN        = 0x00080000L;
2657const auto GCP_MAXEXTENT      = 0x00100000L;
2658const auto GCP_JUSTIFYIN      = 0x00200000L;
2659const auto GCP_DISPLAYZWG      = 0x00400000L;
2660const auto GCP_SYMSWAPOFF      = 0x00800000L;
2661const auto GCP_NUMERICOVERRIDE = 0x01000000L;
2662const auto GCP_NEUTRALOVERRIDE = 0x02000000L;
2663const auto GCP_NUMERICSLATIN   = 0x04000000L;
2664const auto GCP_NUMERICSLOCAL   = 0x08000000L;
2665
2666const auto GCPCLASS_LATIN                  = 1;
2667const auto GCPCLASS_HEBREW                 = 2;
2668const auto GCPCLASS_ARABIC                 = 2;
2669const auto GCPCLASS_NEUTRAL                = 3;
2670const auto GCPCLASS_LOCALNUMBER            = 4;
2671const auto GCPCLASS_LATINNUMBER            = 5;
2672const auto GCPCLASS_LATINNUMERICTERMINATOR = 6;
2673const auto GCPCLASS_LATINNUMERICSEPARATOR  = 7;
2674const auto GCPCLASS_NUMERICSEPARATOR       = 8;
2675const auto GCPCLASS_PREBOUNDLTR         = 0x80;
2676const auto GCPCLASS_PREBOUNDRTL         = 0x40;
2677const auto GCPCLASS_POSTBOUNDLTR        = 0x20;
2678const auto GCPCLASS_POSTBOUNDRTL        = 0x10;
2679
2680const auto GCPGLYPH_LINKBEFORE          = 0x8000;
2681const auto GCPGLYPH_LINKAFTER           = 0x4000;
2682
2683struct GCP_RESULTSA {
2684    DWORD   lStructSize;
2685    LPSTR     lpOutString;
2686    UINT *lpOrder;
2687    int   *lpDx;
2688    int   *lpCaretPos;
2689    LPSTR   lpClass;
2690    LPWSTR  lpGlyphs;
2691    UINT    nGlyphs;
2692    int     nMaxFit;
2693}
2694
2695typedef GCP_RESULTSA* LPGCP_RESULTSA;
2696
2697struct GCP_RESULTSW {
2698    DWORD   lStructSize;
2699    LPWSTR    lpOutString;
2700    UINT *lpOrder;
2701    int   *lpDx;
2702    int   *lpCaretPos;
2703    LPSTR   lpClass;
2704    LPWSTR  lpGlyphs;
2705    UINT    nGlyphs;
2706    int     nMaxFit;
2707}
2708
2709typedef GCP_RESULTSW* LPGCP_RESULTSW;
2710
2711version(UNICODE) {
2712	typedef GCP_RESULTSW GCP_RESULTS;
2713	typedef LPGCP_RESULTSW LPGCP_RESULTS;
2714}
2715else {
2716	typedef GCP_RESULTSA GCP_RESULTS;
2717	typedef LPGCP_RESULTSA LPGCP_RESULTS;
2718}
2719
2720struct RASTERIZER_STATUS {
2721    short   nSize;
2722    short   wFlags;
2723    short   nLanguageID;
2724}
2725
2726typedef RASTERIZER_STATUS* LPRASTERIZER_STATUS;
2727
2728/* bits defined in wFlags of RASTERIZER_STATUS */
2729const auto TT_AVAILABLE    = 0x0001;
2730const auto TT_ENABLED      = 0x0002;
2731
2732/* Pixel format descriptor */
2733struct PIXELFORMATDESCRIPTOR {
2734    WORD  nSize;
2735    WORD  nVersion;
2736    DWORD dwFlags;
2737    BYTE  iPixelType;
2738    BYTE  cColorBits;
2739    BYTE  cRedBits;
2740    BYTE  cRedShift;
2741    BYTE  cGreenBits;
2742    BYTE  cGreenShift;
2743    BYTE  cBlueBits;
2744    BYTE  cBlueShift;
2745    BYTE  cAlphaBits;
2746    BYTE  cAlphaShift;
2747    BYTE  cAccumBits;
2748    BYTE  cAccumRedBits;
2749    BYTE  cAccumGreenBits;
2750    BYTE  cAccumBlueBits;
2751    BYTE  cAccumAlphaBits;
2752    BYTE  cDepthBits;
2753    BYTE  cStencilBits;
2754    BYTE  cAuxBuffers;
2755    BYTE  iLayerType;
2756    BYTE  bReserved;
2757    DWORD dwLayerMask;
2758    DWORD dwVisibleMask;
2759    DWORD dwDamageMask;
2760}
2761
2762typedef PIXELFORMATDESCRIPTOR* PPIXELFORMATDESCRIPTOR;
2763typedef PIXELFORMATDESCRIPTOR* LPPIXELFORMATDESCRIPTOR;
2764
2765/* pixel types */
2766const auto PFD_TYPE_RGBA        = 0;
2767const auto PFD_TYPE_COLORINDEX  = 1;
2768
2769/* layer types */
2770const auto PFD_MAIN_PLANE       = 0;
2771const auto PFD_OVERLAY_PLANE    = 1;
2772const auto PFD_UNDERLAY_PLANE   = (-1);
2773
2774/* PIXELFORMATDESCRIPTOR flags */
2775const auto PFD_DOUBLEBUFFER            = 0x00000001;
2776const auto PFD_STEREO                  = 0x00000002;
2777const auto PFD_DRAW_TO_WINDOW          = 0x00000004;
2778const auto PFD_DRAW_TO_BITMAP          = 0x00000008;
2779const auto PFD_SUPPORT_GDI             = 0x00000010;
2780const auto PFD_SUPPORT_OPENGL          = 0x00000020;
2781const auto PFD_GENERIC_FORMAT          = 0x00000040;
2782const auto PFD_NEED_PALETTE            = 0x00000080;
2783const auto PFD_NEED_SYSTEM_PALETTE     = 0x00000100;
2784const auto PFD_SWAP_EXCHANGE           = 0x00000200;
2785const auto PFD_SWAP_COPY               = 0x00000400;
2786const auto PFD_SWAP_LAYER_BUFFERS      = 0x00000800;
2787const auto PFD_GENERIC_ACCELERATED     = 0x00001000;
2788const auto PFD_SUPPORT_DIRECTDRAW      = 0x00002000;
2789const auto PFD_DIRECT3D_ACCELERATED    = 0x00004000;
2790const auto PFD_SUPPORT_COMPOSITION     = 0x00008000;
2791
2792/* PIXELFORMATDESCRIPTOR flags for use in ChoosePixelFormat only */
2793const auto PFD_DEPTH_DONTCARE          = 0x20000000;
2794const auto PFD_DOUBLEBUFFER_DONTCARE   = 0x40000000;
2795const auto PFD_STEREO_DONTCARE         = 0x80000000;
2796
2797typedef int function(LOGFONTA*, TEXTMETRICA*, DWORD, LPARAM) OLDFONTENUMPROCA;
2798typedef int function(LOGFONTW*, TEXTMETRICW*, DWORD, LPARAM) OLDFONTENUMPROCW;
2799
2800version (UNICODE) {
2801	alias OLDFONTENUMPROCW  OLDFONTENUMPROC;
2802}
2803else {
2804	alias OLDFONTENUMPROCA  OLDFONTENUMPROC;
2805}
2806
2807typedef OLDFONTENUMPROCA    FONTENUMPROCA;
2808typedef OLDFONTENUMPROCW    FONTENUMPROCW;
2809
2810version (UNICODE) {
2811	typedef FONTENUMPROCW FONTENUMPROC;
2812}
2813else {
2814	typedef FONTENUMPROCA FONTENUMPROC;
2815}
2816
2817typedef int function (LPVOID, LPARAM) GOBJENUMPROC;
2818typedef VOID function(int, int, LPARAM) LINEDDAPROC;
2819
2820int AddFontResourceA(LPCSTR);
2821int AddFontResourceW(LPCWSTR);
2822
2823version (UNICODE) {
2824	alias AddFontResourceW AddFontResource;
2825}
2826else {
2827	alias AddFontResourceA AddFontResource;
2828}
2829
2830BOOL  AnimatePalette(HPALETTE hPal, UINT iStartIndex, UINT cEntries, PALETTEENTRY* ppe);
2831BOOL  Arc(HDC hdc,int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4);
2832BOOL  BitBlt(HDC hdc,int x,int y,int cx,int cy,HDC hdcSrc,int x1,int y1,DWORD rop);
2833BOOL  CancelDC(HDC hdc);
2834BOOL  Chord(HDC hdc,int x1,int y1,int x2,int y2,int x3,int y3,int x4,int y4);
2835int   ChoosePixelFormat(HDC hdc,PIXELFORMATDESCRIPTOR *ppfd);
2836HMETAFILE  CloseMetaFile(HDC hdc);
2837int     CombineRgn(HRGN hrgnDst,HRGN hrgnSrc1,HRGN hrgnSrc2,int iMode);
2838HMETAFILE CopyMetaFileA(HMETAFILE,LPCSTR);
2839HMETAFILE CopyMetaFileW(HMETAFILE,LPCWSTR);
2840
2841version(UNICODE) {
2842	alias CopyMetaFileW  CopyMetaFile;
2843}
2844else {
2845	alias CopyMetaFileA  CopyMetaFile;
2846}
2847
2848HBITMAP CreateBitmap(int nWidth,int nHeight,UINT nPlanes,UINT nBitCount,VOID *lpBits);
2849HBITMAP CreateBitmapIndirect(BITMAP *pbm);
2850HBRUSH  CreateBrushIndirect(LOGBRUSH *plbrush);
2851HBITMAP CreateCompatibleBitmap(HDC hdc,int cx,int cy);
2852HBITMAP CreateDiscardableBitmap(HDC hdc,int cx,int cy);
2853HDC     CreateCompatibleDC(HDC hdc);
2854HDC     CreateDCA(LPCSTR pwszDriver,LPCSTR pwszDevice,LPCSTR pszPort,DEVMODEA * pdm);
2855HDC     CreateDCW(LPCWSTR pwszDriver,LPCWSTR pwszDevice,LPCWSTR pszPort,DEVMODEW * pdm);
2856
2857version(UNICODE) {
2858	alias CreateDCW  CreateDC;
2859}
2860else {
2861	alias CreateDCA  CreateDC;
2862}
2863
2864HBITMAP CreateDIBitmap(HDC hdc,BITMAPINFOHEADER *pbmih,DWORD flInit,VOID *pjBits,BITMAPINFO *pbmi,UINT iUsage);
2865HBRUSH  CreateDIBPatternBrush(HGLOBAL h,UINT iUsage);
2866HBRUSH  CreateDIBPatternBrushPt(VOID *lpPackedDIB,UINT iUsage);
2867HRGN    CreateEllipticRgn(int x1,int y1,int x2,int y2);
2868HRGN    CreateEllipticRgnIndirect(RECT *lprect);
2869HFONT   CreateFontIndirectA(LOGFONTA *lplf);
2870HFONT   CreateFontIndirectW(LOGFONTW *lplf);
2871
2872version(UNICODE) {
2873	alias CreateFontIndirectW  CreateFontIndirect;
2874}
2875else {
2876	alias CreateFontIndirectA  CreateFontIndirect;
2877}
2878
2879HFONT   CreateFontA(int cHeight,int cWidth,int cEscapement,int cOrientation,int cWeight,DWORD bItalic,
2880                            DWORD bUnderline,DWORD bStrikeOut,DWORD iCharSet,DWORD iOutPrecision,DWORD iClipPrecision,
2881                            DWORD iQuality,DWORD iPitchAndFamily,LPCSTR pszFaceName);
2882HFONT   CreateFontW(int cHeight,int cWidth,int cEscapement,int cOrientation,int cWeight,DWORD bItalic,
2883                            DWORD bUnderline,DWORD bStrikeOut,DWORD iCharSet,DWORD iOutPrecision,DWORD iClipPrecision,
2884                            DWORD iQuality,DWORD iPitchAndFamily,LPCWSTR pszFaceName);
2885
2886version(UNICODE) {
2887	alias CreateFontW  CreateFont;
2888}
2889else {
2890	alias CreateFontA  CreateFont;
2891}
2892
2893HBRUSH  CreateHatchBrush(int iHatch,COLORREF color);
2894HDC     CreateICA(LPCSTR pszDriver,LPCSTR pszDevice,LPCSTR pszPort,DEVMODEA * pdm);
2895HDC     CreateICW(LPCWSTR pszDriver,LPCWSTR pszDevice,LPCWSTR pszPort,DEVMODEW * pdm);
2896
2897version(UNICODE) {
2898	alias CreateICW  CreateIC;
2899}
2900else {
2901	alias CreateICA  CreateIC;
2902}
2903
2904HDC     CreateMetaFileA(LPCSTR pszFile);
2905HDC     CreateMetaFileW(LPCWSTR pszFile);
2906
2907version(UNICODE) {
2908	alias CreateMetaFileW  CreateMetaFile;
2909}
2910else {
2911	alias CreateMetaFileA  CreateMetaFile;
2912}
2913
2914HPALETTE CreatePalette( LOGPALETTE * plpal);
2915HPEN    CreatePen(int iStyle,int cWidth,COLORREF color);
2916HPEN    CreatePenIndirect(LOGPEN *plpen);
2917HRGN    CreatePolyPolygonRgn( POINT *pptl,
2918                                               INT  *pc,
2919                                               int cPoly,
2920                                               int iMode);
2921HBRUSH  CreatePatternBrush(HBITMAP hbm);
2922HRGN    CreateRectRgn(int x1,int y1,int x2,int y2);
2923HRGN    CreateRectRgnIndirect(RECT *lprect);
2924HRGN    CreateRoundRectRgn(int x1,int y1,int x2,int y2,int w,int h);
2925BOOL    CreateScalableFontResourceA(DWORD fdwHidden,LPCSTR lpszFont,LPCSTR lpszFile,LPCSTR lpszPath);
2926BOOL    CreateScalableFontResourceW(DWORD fdwHidden,LPCWSTR lpszFont,LPCWSTR lpszFile,LPCWSTR lpszPath);
2927
2928version(UNICODE) {
2929	alias CreateScalableFontResourceW  CreateScalableFontResource;
2930}
2931else {
2932	alias CreateScalableFontResourceA  CreateScalableFontResource;
2933}
2934
2935HBRUSH  CreateSolidBrush(COLORREF color);
2936
2937BOOL DeleteDC(HDC hdc);
2938BOOL DeleteMetaFile(HMETAFILE hmf);
2939BOOL DeleteObject(HGDIOBJ ho);
2940int  DescribePixelFormat( HDC hdc,
2941                                           int iPixelFormat,
2942                                           UINT nBytes,LPPIXELFORMATDESCRIPTOR ppfd);
2943
2944/* define types of pointers to ExtDeviceMode() and DeviceCapabilities()
2945 * functions for Win 3.1 compatibility
2946 */
2947
2948typedef UINT function(HWND, HMODULE, LPDEVMODE, LPSTR, LPSTR, LPDEVMODE, LPSTR, UINT) LPFNDEVMODE;
2949typedef DWORD function(LPSTR, LPSTR, UINT, LPSTR, LPDEVMODE) LPFNDEVCAPS;
2950
2951/* mode selections for the device mode function */
2952// import windef.d:
2953/*const auto DM_UPDATE           = 1;
2954const auto DM_COPY             = 2;
2955const auto DM_PROMPT           = 4;
2956const auto DM_MODIFY           = 8;*/
2957
2958// import windef.d:
2959/*const auto DM_IN_BUFFER        = DM_MODIFY;
2960const auto DM_IN_PROMPT        = DM_PROMPT;
2961const auto DM_OUT_BUFFER       = DM_COPY;
2962const auto DM_OUT_DEFAULT      = DM_UPDATE;*/
2963
2964/* device capabilities indices */
2965// import windef.d:
2966/*const auto DC_FIELDS           = 1;
2967const auto DC_PAPERS           = 2;
2968const auto DC_PAPERSIZE        = 3;
2969const auto DC_MINEXTENT        = 4;
2970const auto DC_MAXEXTENT        = 5;
2971const auto DC_BINS             = 6;
2972const auto DC_DUPLEX           = 7;
2973const auto DC_SIZE             = 8;
2974const auto DC_EXTRA            = 9;
2975const auto DC_VERSION          = 10;
2976const auto DC_DRIVER           = 11;
2977const auto DC_BINNAMES         = 12;
2978const auto DC_ENUMRESOLUTIONS  = 13;
2979const auto DC_FILEDEPENDENCIES = 14;
2980const auto DC_TRUETYPE         = 15;
2981const auto DC_PAPERNAMES       = 16;
2982const auto DC_ORIENTATION      = 17;
2983const auto DC_COPIES           = 18;*/
2984
2985const auto DC_BINADJUST            = 19;
2986const auto DC_EMF_COMPLIANT        = 20;
2987const auto DC_DATATYPE_PRODUCED    = 21;
2988const auto DC_COLLATE              = 22;
2989const auto DC_MANUFACTURER         = 23;
2990const auto DC_MODEL                = 24;
2991
2992const auto DC_PERSONALITY          = 25;
2993const auto DC_PRINTRATE            = 26;
2994const auto DC_PRINTRATEUNIT        = 27;
2995const auto   PRINTRATEUNIT_PPM     = 1;
2996const auto   PRINTRATEUNIT_CPS     = 2;
2997const auto   PRINTRATEUNIT_LPM     = 3;
2998const auto   PRINTRATEUNIT_IPM     = 4;
2999const auto DC_PRINTERMEM           = 28;
3000const auto DC_MEDIAREADY           = 29;
3001const auto DC_STAPLE               = 30;
3002const auto DC_PRINTRATEPPM         = 31;
3003const auto DC_COLORDEVICE          = 32;
3004const auto DC_NUP                  = 33;
3005
3006const auto DC_MEDIATYPENAMES       = 34;
3007const auto DC_MEDIATYPES           = 35;
3008
3009/* bit fields of the return value (DWORD) for DC_TRUETYPE */
3010const auto DCTT_BITMAP             = 0x0000001L;
3011const auto DCTT_DOWNLOAD           = 0x0000002L;
3012const auto DCTT_SUBDEV             = 0x0000004L;
3013
3014const auto DCTT_DOWNLOAD_OUTLINE   = 0x0000008L;
3015
3016/* return values for DC_BINADJUST */
3017const auto DCBA_FACEUPNONE       = 0x0000;
3018const auto DCBA_FACEUPCENTER     = 0x0001;
3019const auto DCBA_FACEUPLEFT       = 0x0002;
3020const auto DCBA_FACEUPRIGHT      = 0x0003;
3021const auto DCBA_FACEDOWNNONE     = 0x0100;
3022const auto DCBA_FACEDOWNCENTER   = 0x0101;
3023const auto DCBA_FACEDOWNLEFT     = 0x0102;
3024const auto DCBA_FACEDOWNRIGHT    = 0x0103;
3025
3026int DeviceCapabilitiesA(
3027                  LPCSTR         pDevice,
3028              LPCSTR         pPort,
3029                  WORD             fwCapability,
3030    	LPSTR          pOutput,
3031              DEVMODEA   *pDevMode
3032    );
3033
3034int DeviceCapabilitiesW(
3035                  LPCWSTR         pDevice,
3036              LPCWSTR         pPort,
3037                  WORD             fwCapability,
3038    LPWSTR          pOutput,
3039              DEVMODEW   *pDevMode
3040    );
3041
3042version(UNICODE) {
3043	alias DeviceCapabilitiesW  DeviceCapabilities;
3044}
3045else {
3046	alias DeviceCapabilitiesA  DeviceCapabilities;
3047}
3048
3049int  DrawEscape(  HDC    hdc,
3050                                   int    iEscape,
3051                                   int    cjIn,
3052								   LPCSTR lpIn);
3053
3054BOOL Ellipse(HDC hdc,int left,int top, int right,int bottom);
3055
3056int  EnumFontFamiliesExA(HDC hdc,LPLOGFONTA lpLogfont,FONTENUMPROCA lpProc,LPARAM lParam,DWORD dwFlags);
3057int  EnumFontFamiliesExW(HDC hdc,LPLOGFONTW lpLogfont,FONTENUMPROCW lpProc,LPARAM lParam,DWORD dwFlags);
3058
3059version(UNICODE) {
3060	alias EnumFontFamiliesExW  EnumFontFamiliesEx;
3061}
3062else {
3063	alias EnumFontFamiliesExA  EnumFontFamiliesEx;
3064}
3065
3066int  EnumFontFamiliesA(HDC hdc,LPCSTR lpLogfont,FONTENUMPROCA lpProc,LPARAM lParam);
3067int  EnumFontFamiliesW(HDC hdc,LPCWSTR lpLogfont,FONTENUMPROCW lpProc,LPARAM lParam);
3068
3069version(UNICODE) {
3070	alias EnumFontFamiliesW  EnumFontFamiliesW;
3071}
3072else {
3073	alias EnumFontFamiliesA  EnumFontFamiliesA;
3074}
3075int  EnumFontsA(HDC hdc,LPCSTR lpLogfont, FONTENUMPROCA lpProc,LPARAM lParam);
3076int  EnumFontsW(HDC hdc,LPCWSTR lpLogfont, FONTENUMPROCW lpProc,LPARAM lParam);
3077
3078version(UNICODE) {
3079	alias EnumFontsW  EnumFonts;
3080}
3081else {
3082	alias EnumFontsA  EnumFonts;
3083}
3084
3085int  EnumObjects(HDC hdc,int nType,GOBJENUMPROC lpFunc,LPVOID lParam);
3086
3087BOOL EqualRgn(HRGN hrgn1,HRGN hrgn2);
3088int  Escape(  HDC hdc,
3089                               int iEscape,
3090                               int cjIn,
3091                                LPCSTR pvIn,
3092                                LPVOID pvOut);
3093int  ExtEscape(   HDC hdc,
3094                                   int iEscape,
3095                                   int cjInput,
3096                                    LPCSTR lpInData,
3097                                   int cjOutput,
3098                                    LPSTR lpOutData);
3099int  ExcludeClipRect(HDC hdc,int left,int top,int right,int bottom);
3100HRGN ExtCreateRegion(XFORM * lpx,DWORD nCount, RGNDATA * lpData);
3101BOOL ExtFloodFill(HDC hdc,int x,int y,COLORREF color,UINT type);
3102BOOL FillRgn(HDC hdc,HRGN hrgn,HBRUSH hbr);
3103BOOL FloodFill(HDC hdc,int x,int y,COLORREF color);
3104BOOL FrameRgn(HDC hdc,HRGN hrgn,HBRUSH hbr,int w,int h);
3105int  GetROP2(HDC hdc);
3106BOOL GetAspectRatioFilterEx(HDC hdc,LPSIZE lpsize);
3107COLORREF GetBkColor(HDC hdc);
3108
3109COLORREF GetDCBrushColor(HDC hdc);
3110COLORREF GetDCPenColor(HDC hdc);
3111
3112int GetBkMode(HDC hdc);
3113
3114LONG GetBitmapBits(
3115   HBITMAP hbit,
3116   LONG cb,
3117    LPVOID lpvBits
3118    );
3119
3120BOOL  GetBitmapDimensionEx(HBITMAP hbit,LPSIZE lpsize);
3121UINT  GetBoundsRect(HDC hdc,LPRECT lprect,UINT flags);
3122
3123BOOL  GetBrushOrgEx(HDC hdc,LPPOINT lppt);
3124
3125BOOL  GetCharWidthA(HDC hdc,UINT iFirst,UINT iLast, LPINT lpBuffer);
3126BOOL  GetCharWidthW(HDC hdc,UINT iFirst,UINT iLast, LPINT lpBuffer);
3127
3128version(UNICODE) {
3129	alias GetCharWidthW  GetCharWidth;
3130}
3131else {
3132	alias GetCharWidthA  GetCharWidth;
3133}
3134
3135BOOL  GetCharWidth32A(HDC hdc,UINT iFirst,UINT iLast,  LPINT lpBuffer);
3136BOOL  GetCharWidth32W(HDC hdc,UINT iFirst,UINT iLast,  LPINT lpBuffer);
3137
3138version(UNICODE) {
3139	alias GetCharWidth32W  GetCharWidth32;
3140}
3141else {
3142	alias GetCharWidth32A  GetCharWidth32;
3143}
3144BOOL  GetCharWidthFloatA(HDC hdc,UINT iFirst,UINT iLast, PFLOAT lpBuffer);
3145BOOL GetCharWidthFloatW(HDC hdc,UINT iFirst,UINT iLast, PFLOAT lpBuffer);
3146
3147version(UNICODE) {
3148	alias GetCharWidthFloatW  GetCharWidthFloat;
3149}
3150else {
3151	alias GetCharWidthFloatA  GetCharWidthFloat;
3152}
3153
3154BOOL GetCharABCWidthsA(HDC hdc,
3155                                           UINT wFirst,
3156                                           UINT wLast,
3157                                           LPABC lpABC);
3158BOOL GetCharABCWidthsW(HDC hdc,
3159                                           UINT wFirst,
3160                                           UINT wLast,
3161                                            LPABC lpABC);
3162version(UNICODE) {
3163	alias GetCharABCWidthsW  GetCharABCWidths;
3164}
3165else {
3166	alias GetCharABCWidthsA  GetCharABCWidths;
3167}
3168
3169BOOL GetCharABCWidthsFloatA(HDC hdc,UINT iFirst,UINT iLast, LPABCFLOAT lpABC);
3170BOOL GetCharABCWidthsFloatW(HDC hdc,UINT iFirst,UINT iLast, LPABCFLOAT lpABC);
3171
3172version(UNICODE) {
3173	alias GetCharABCWidthsFloatW  GetCharABCWidthsFloat;
3174}
3175else {
3176	alias GetCharABCWidthsFloatA  GetCharABCWidthsFloat;
3177}
3178
3179int   GetClipBox(HDC hdc, LPRECT lprect);
3180int   GetClipRgn(HDC hdc,HRGN hrgn);
3181int   GetMetaRgn(HDC hdc,HRGN hrgn);
3182HGDIOBJ GetCurrentObject(HDC hdc,UINT type);
3183BOOL  GetCurrentPositionEx(HDC hdc, LPPOINT lppt);
3184int   GetDeviceCaps(HDC hdc,int index);
3185int   GetDIBits(HDC hdc,HBITMAP hbm,UINT start,UINT cLines,  LPVOID lpvBits, LPBITMAPINFO lpbmi,UINT usage);  // SAL actual size of lpbmi is computed from structure elements
3186
3187DWORD GetFontData (   HDC     hdc,
3188                                       DWORD   dwTable,
3189                                       DWORD   dwOffset,
3190                                       PVOID pvBuffer,
3191                                       DWORD   cjBuffer
3192                                        );
3193
3194DWORD GetGlyphOutlineA(   HDC hdc,
3195                                           UINT uChar,
3196                                           UINT fuFormat,
3197                                           LPGLYPHMETRICS lpgm,
3198                                           DWORD cjBuffer,
3199                                           LPVOID pvBuffer,
3200                                           MAT2 *lpmat2
3201                                        );
3202DWORD GetGlyphOutlineW(   HDC hdc,
3203                                           UINT uChar,
3204                                           UINT fuFormat,
3205                                           LPGLYPHMETRICS lpgm,
3206                                           DWORD cjBuffer,
3207                                           LPVOID pvBuffer,
3208                                           MAT2 *lpmat2
3209                                        );
3210
3211version(UNICODE) {
3212	alias GetGlyphOutlineW  GetGlyphOutline;
3213}
3214else {
3215	alias GetGlyphOutlineA  GetGlyphOutline;
3216}
3217
3218int   GetGraphicsMode(HDC hdc);
3219int   GetMapMode(HDC hdc);
3220UINT  GetMetaFileBitsEx(HMETAFILE hMF,UINT cbBuffer, LPVOID lpData);
3221HMETAFILE   GetMetaFileA(LPCSTR lpName);
3222HMETAFILE   GetMetaFileW(LPCWSTR lpName);
3223
3224version(UNICODE) {
3225	alias GetMetaFileW  GetMetaFile;
3226}
3227else {
3228	alias GetMetaFileA  GetMetaFile;
3229}
3230
3231COLORREF GetNearestColor(HDC hdc,COLORREF color);
3232UINT  GetNearestPaletteIndex(HPALETTE h,COLORREF color);
3233DWORD GetObjectType(HGDIOBJ h);
3234
3235UINT GetOutlineTextMetricsA(HDC hdc,
3236                                               UINT cjCopy,
3237                                               LPOUTLINETEXTMETRICA potm);
3238UINT GetOutlineTextMetricsW(HDC hdc,
3239                                               UINT cjCopy,
3240                                               LPOUTLINETEXTMETRICW potm);
3241
3242version(UNICODE) {
3243	alias GetOutlineTextMetricsW  GetOutlineTextMetrics;
3244}
3245else {
3246	alias GetOutlineTextMetricsA  GetOutlineTextMetrics;
3247}
3248
3249UINT  GetPaletteEntries(  HPALETTE hpal,
3250                                           UINT iStart,
3251                                           UINT cEntries,
3252                                           LPPALETTEENTRY pPalEntries);
3253COLORREF GetPixel(HDC hdc,int x,int y);
3254int   GetPixelFormat(HDC hdc);
3255int   GetPolyFillMode(HDC hdc);
3256BOOL  GetRasterizerCaps(LPRASTERIZER_STATUS lpraststat,
3257                                           UINT cjBytes);
3258
3259int   GetRandomRgn (HDC hdc,HRGN hrgn,INT i);
3260DWORD GetRegionData(  HRGN hrgn,
3261                                       DWORD nCount,
3262                                       LPRGNDATA lpRgnData);
3263int   GetRgnBox(HRGN hrgn, LPRECT lprc);
3264HGDIOBJ GetStockObject(int i);
3265int   GetStretchBltMode(HDC hdc);
3266
3267UINT GetSystemPaletteEntries(
3268   HDC  hdc,
3269   UINT iStart,
3270   UINT cEntries,
3271   LPPALETTEENTRY pPalEntries
3272);
3273
3274UINT  GetSystemPaletteUse(HDC hdc);
3275int   GetTextCharacterExtra(HDC hdc);
3276UINT  GetTextAlign(HDC hdc);
3277COLORREF GetTextColor(HDC hdc);
3278
3279BOOL GetTextExtentPointA(
3280   HDC hdc,
3281   LPCSTR lpString,
3282   int c,
3283   LPSIZE lpsz );
3284
3285BOOL GetTextExtentPointW(
3286   HDC hdc,
3287   LPCWSTR lpString,
3288   int c,
3289   LPSIZE lpsz
3290    );
3291
3292version(UNICODE) {
3293	alias GetTextExtentPointW  GetTextExtentPoint;
3294}
3295else {
3296	alias GetTextExtentPointA  GetTextExtentPoint;
3297}
3298
3299BOOL GetTextExtentPoint32A(
3300   HDC hdc,
3301   LPCSTR lpString,
3302   int c,
3303   LPSIZE psizl
3304);
3305
3306BOOL GetTextExtentPoint32W(
3307   HDC hdc,
3308   LPCWSTR lpString,
3309   int c,
3310   LPSIZE psizl
3311);
3312
3313version(UNICODE) {
3314	alias GetTextExtentPoint32W  GetTextExtentPoint32;
3315}
3316else {
3317	alias GetTextExtentPoint32A  GetTextExtentPoint32;
3318}
3319
3320BOOL GetTextExtentExPointA(
3321   HDC hdc,
3322   LPCSTR lpszString,
3323   int cchString,
3324   int nMaxExtent,
3325    LPINT lpnFit,
3326   LPINT lpnDx,
3327   LPSIZE lpSize
3328    );
3329
3330BOOL GetTextExtentExPointW(
3331   HDC hdc,
3332  LPCWSTR lpszString,
3333   int cchString,
3334   int nMaxExtent,
3335    LPINT lpnFit,
3336   LPINT lpnDx,
3337   LPSIZE lpSize
3338    );
3339
3340version(UNICODE) {
3341	alias GetTextExtentExPointW  GetTextExtentExPoint;
3342}
3343else {
3344	alias GetTextExtentExPointA  GetTextExtentExPoint;
3345}
3346
3347int GetTextCharset(HDC hdc);
3348int GetTextCharsetInfo(HDC hdc, LPFONTSIGNATURE lpSig,DWORD dwFlags);
3349BOOL TranslateCharsetInfo(DWORD *lpSrc, LPCHARSETINFO lpCs,DWORD dwFlags);
3350DWORD GetFontLanguageInfo(HDC hdc);
3351DWORD GetCharacterPlacementA( HDC hdc, LPCSTR lpString,int nCount,int nMexExtent,LPGCP_RESULTSA lpResults,DWORD dwFlags);
3352DWORD GetCharacterPlacementW( HDC hdc, LPCWSTR lpString,int nCount,int nMexExtent,LPGCP_RESULTSW lpResults,DWORD dwFlags);
3353
3354version(UNICODE) {
3355	alias GetCharacterPlacementW  GetCharacterPlacement;
3356}
3357else {
3358	alias GetCharacterPlacementA  GetCharacterPlacement;
3359}
3360
3361struct WCRANGE {
3362    WCHAR  wcLow;
3363    USHORT cGlyphs;
3364}
3365
3366typedef WCRANGE* PWCRANGE;
3367typedef WCRANGE* LPWCRANGE;
3368
3369struct GLYPHSET {
3370    DWORD    cbThis;
3371    DWORD    flAccel;
3372    DWORD    cGlyphsSupported;
3373    DWORD    cRanges;
3374    WCRANGE  ranges[1];
3375}
3376
3377typedef GLYPHSET* PGLYPHSET;
3378typedef GLYPHSET* LPGLYPHSET;
3379
3380/* flAccel flags for the GLYPHSET structure above */
3381
3382const auto GS_8BIT_INDICES     = 0x00000001;
3383
3384/* flags for GetGlyphIndices */
3385
3386const auto GGI_MARK_NONEXISTING_GLYPHS  = 0x0001;
3387
3388DWORD GetFontUnicodeRanges(HDC hdc, LPGLYPHSET lpgs);
3389DWORD GetGlyphIndicesA(HDC hdc, LPCSTR lpstr,int c, LPWORD pgi,DWORD fl);
3390DWORD GetGlyphIndicesW(HDC hdc, LPCWSTR lpstr,int c, LPWORD pgi,DWORD fl);
3391
3392version(UNICODE) {
3393	alias GetGlyphIndicesW  GetGlyphIndices;
3394}
3395else {
3396	alias GetGlyphIndicesA  GetGlyphIndices;
3397}
3398
3399BOOL  GetTextExtentPointI(HDC hdc, LPWORD pgiIn,int cgi,LPSIZE psize);
3400BOOL  GetTextExtentExPointI ( HDC hdc,
3401                                                LPWORD lpwszString,
3402                                               int cwchString,
3403                                               int nMaxExtent,
3404                                                LPINT lpnFit,
3405                                                 LPINT lpnDx,
3406                                               LPSIZE lpSize
3407                                                );
3408
3409BOOL  GetCharWidthI(  HDC hdc,
3410                                       UINT giFirst,
3411                                       UINT cgi,
3412                                        LPWORD pgi,
3413                                        LPINT piWidths
3414                                        );
3415
3416BOOL  GetCharABCWidthsI(  HDC    hdc,
3417                                           UINT   giFirst,
3418                                           UINT   cgi,
3419                                            LPWORD pgi,
3420                                            LPABC  pabc
3421                                        );
3422
3423
3424const auto STAMP_DESIGNVECTOR  = (0x8000000 + cast(uint)'d' + (cast(uint)'v' << 8));
3425const auto STAMP_AXESLIST      = (0x8000000 + cast(uint)'a' + (cast(uint)'l' << 8));
3426const auto MM_MAX_NUMAXES      = 16;
3427
3428
3429
3430struct DESIGNVECTOR {
3431    DWORD  dvReserved;
3432    DWORD  dvNumAxes;
3433    LONG   dvValues[MM_MAX_NUMAXES];
3434}
3435
3436typedef DESIGNVECTOR* PDESIGNVECTOR;
3437typedef DESIGNVECTOR* LPDESIGNVECTOR;
3438
3439int  AddFontResourceExA(LPCSTR name,DWORD fl,PVOID res);
3440int  AddFontResourceExW(LPCWSTR name,DWORD fl,PVOID res);
3441
3442version(UNICODE) {
3443	alias AddFontResourceExW  AddFontResourceEx;
3444}
3445else {
3446	alias AddFontResourceExA  AddFontResourceEx;
3447}
3448
3449BOOL RemoveFontResourceExA(LPCSTR name,DWORD fl,PVOID pdv);
3450BOOL RemoveFontResourceExW(LPCWSTR name,DWORD fl,PVOID pdv);
3451
3452version(UNICODE) {
3453	alias RemoveFontResourceExW  RemoveFontResourceEx;
3454}
3455else {
3456	alias RemoveFontResourceExA  RemoveFontResourceEx;
3457}
3458
3459HANDLE AddFontMemResourceEx(   PVOID pFileView,
3460                                               DWORD cjSize,
3461                                               PVOID pvResrved,
3462                                               DWORD* pNumFonts);
3463
3464BOOL RemoveFontMemResourceEx(HANDLE h);
3465const auto FR_PRIVATE     = 0x10;
3466const auto FR_NOT_ENUM    = 0x20;
3467
3468// The actual size of the DESIGNVECTOR and ENUMLOGFONTEXDV structures
3469// is determined by dvNumAxes,
3470// MM_MAX_NUMAXES only detemines the maximal size allowed
3471
3472const auto MM_MAX_AXES_NAMELEN = 16;
3473
3474struct AXISINFOA {
3475    LONG   axMinValue;
3476    LONG   axMaxValue;
3477    BYTE[MM_MAX_AXES_NAMELEN]   axAxisName;
3478}
3479
3480typedef AXISINFOA* PAXISINFOA;
3481typedef AXISINFOA* LPAXISINFOA;
3482
3483struct AXISINFOW {
3484    LONG   axMinValue;
3485    LONG   axMaxValue;
3486    WCHAR[MM_MAX_AXES_NAMELEN]  axAxisName;
3487}
3488
3489typedef AXISINFOW* PAXISINFOW;
3490typedef AXISINFOW* LPAXISINFOW;
3491
3492version(UNICODE) {
3493	typedef AXISINFOW AXISINFO;
3494	typedef PAXISINFOW PAXISINFO;
3495	typedef LPAXISINFOW LPAXISINFO;
3496}
3497else {
3498	typedef AXISINFOA AXISINFO;
3499	typedef PAXISINFOA PAXISINFO;
3500	typedef LPAXISINFOA LPAXISINFO;
3501}
3502
3503struct AXESLISTA {
3504    DWORD     axlReserved;
3505    DWORD     axlNumAxes;
3506    AXISINFOA[MM_MAX_NUMAXES] axlAxisInfo;
3507}
3508
3509typedef AXESLISTA* PAXESLISTA;
3510typedef AXESLISTA* LPAXESLISTA;
3511
3512struct AXESLISTW {
3513    DWORD     axlReserved;
3514    DWORD     axlNumAxes;
3515    AXISINFOW[MM_MAX_NUMAXES] axlAxisInfo;
3516}
3517
3518typedef AXESLISTW* PAXESLISTW;
3519typedef AXESLISTW* LPAXESLISTW;
3520
3521version(UNICODE) {
3522	typedef AXESLISTW AXESLIST;
3523	typedef PAXESLISTW PAXESLIST;
3524	typedef LPAXESLISTW LPAXESLIST;
3525}
3526else {
3527	typedef AXESLISTA AXESLIST;
3528	typedef PAXESLISTA PAXESLIST;
3529	typedef LPAXESLISTA LPAXESLIST;
3530}
3531
3532// The actual size of the AXESLIST and ENUMTEXTMETRIC structure is
3533// determined by axlNumAxes,
3534// MM_MAX_NUMAXES only detemines the maximal size allowed
3535
3536struct ENUMLOGFONTEXDVA {
3537    ENUMLOGFONTEXA elfEnumLogfontEx;
3538    DESIGNVECTOR   elfDesignVector;
3539}
3540
3541typedef ENUMLOGFONTEXDVA* PENUMLOGFONTEXDVA;
3542typedef ENUMLOGFONTEXDVA* LPENUMLOGFONTEXDVA;
3543
3544struct ENUMLOGFONTEXDVW {
3545    ENUMLOGFONTEXW elfEnumLogfontEx;
3546    DESIGNVECTOR   elfDesignVector;
3547}
3548
3549typedef ENUMLOGFONTEXDVW* PENUMLOGFONTEXDVW;
3550typedef ENUMLOGFONTEXDVW* LPENUMLOGFONTEXDVW;
3551
3552version(UNICODE) {
3553	typedef ENUMLOGFONTEXDVW ENUMLOGFONTEXDV;
3554	typedef PENUMLOGFONTEXDVW PENUMLOGFONTEXDV;
3555	typedef LPENUMLOGFONTEXDVW LPENUMLOGFONTEXDV;
3556}
3557else {
3558	typedef ENUMLOGFONTEXDVA ENUMLOGFONTEXDV;
3559	typedef PENUMLOGFONTEXDVA PENUMLOGFONTEXDV;
3560	typedef LPENUMLOGFONTEXDVA LPENUMLOGFONTEXDV;
3561}
3562
3563HFONT  CreateFontIndirectExA(ENUMLOGFONTEXDVA *);
3564HFONT  CreateFontIndirectExW(ENUMLOGFONTEXDVW *);
3565
3566version(UNICODE) {
3567	alias CreateFontIndirectExW  CreateFontIndirectEx;
3568}
3569else {
3570	alias CreateFontIndirectExA  CreateFontIndirectEx;
3571}
3572
3573struct ENUMTEXTMETRICA {
3574    NEWTEXTMETRICEXA etmNewTextMetricEx;
3575    AXESLISTA        etmAxesList;
3576}
3577
3578typedef ENUMTEXTMETRICA* PENUMTEXTMETRICA;
3579typedef ENUMTEXTMETRICA* LPENUMTEXTMETRICA;
3580
3581struct ENUMTEXTMETRICW {
3582    NEWTEXTMETRICEXW etmNewTextMetricEx;
3583    AXESLISTW        etmAxesList;
3584}
3585
3586typedef ENUMTEXTMETRICW* PENUMTEXTMETRICW;
3587typedef ENUMTEXTMETRICW* LPENUMTEXTMETRICW;
3588
3589version(UNICODE) {
3590	typedef ENUMTEXTMETRICW ENUMTEXTMETRIC;
3591	typedef PENUMTEXTMETRICW PENUMTEXTMETRIC;
3592	typedef LPENUMTEXTMETRICW LPENUMTEXTMETRIC;
3593}
3594else {
3595	typedef ENUMTEXTMETRICA ENUMTEXTMETRIC;
3596	typedef PENUMTEXTMETRICA PENUMTEXTMETRIC;
3597	typedef LPENUMTEXTMETRICA LPENUMTEXTMETRIC;
3598}
3599
3600BOOL  GetViewportExtEx(HDC hdc,LPSIZE lpsize);
3601BOOL  GetViewportOrgEx(HDC hdc,LPPOINT lppoint);
3602BOOL  GetWindowExtEx(HDC hdc,LPSIZE lpsize);
3603BOOL  GetWindowOrgEx(HDC hdc,LPPOINT lppoint);
3604
3605int  IntersectClipRect(HDC hdc,int left,int top,int right,int bottom);
3606BOOL InvertRgn(HDC hdc,HRGN hrgn);
3607BOOL LineDDA(int xStart,int yStart,int xEnd,int yEnd,LINEDDAPROC lpProc,LPARAM data);
3608BOOL LineTo(HDC hdc,int x,int y);
3609BOOL MaskBlt(HDC hdcDest,int xDest,int yDest,int width,int height,
3610             HDC hdcSrc,int xSrc,int ySrc,HBITMAP hbmMask,int xMask,int yMask,DWORD rop);
3611BOOL PlgBlt(HDC hdcDest, POINT * lpPoint,HDC hdcSrc,int xSrc,int ySrc,int width,
3612                    int height,HBITMAP hbmMask,int xMask,int yMask);
3613
3614int  OffsetClipRgn(HDC hdc,int x,int y);
3615int  OffsetRgn(HRGN hrgn,int x,int y);
3616BOOL PatBlt(HDC hdc,int x,int y,int w,int h,DWORD rop);
3617BOOL Pie(HDC hdc,int left,int top,int right,int bottom,int xr1,int yr1,int xr2,int yr2);
3618BOOL PlayMetaFile(HDC hdc,HMETAFILE hmf);
3619BOOL PaintRgn(HDC hdc,HRGN hrgn);
3620BOOL PolyPolygon(HDC hdc, POINT *apt,  INT *asz, int csz);
3621BOOL PtInRegion(HRGN hrgn,int x,int y);
3622BOOL PtVisible(HDC hdc,int x,int y);
3623BOOL RectInRegion(HRGN hrgn,RECT * lprect);
3624BOOL RectVisible(HDC hdc,RECT * lprect);
3625BOOL Rectangle(HDC hdc,int left,int top,int right,int bottom);
3626BOOL RestoreDC(HDC hdc,int nSavedDC);
3627HDC  ResetDCA(HDC hdc,DEVMODEA * lpdm);
3628HDC  ResetDCW(HDC hdc,DEVMODEW * lpdm);
3629
3630version(UNICODE) {
3631	alias ResetDCW  ResetDC;
3632}
3633else {
3634	alias ResetDCA  ResetDC;
3635}
3636
3637UINT RealizePalette(HDC hdc);
3638BOOL RemoveFontResourceA(LPCSTR lpFileName);
3639BOOL RemoveFontResourceW(LPCWSTR lpFileName);
3640
3641version(UNICODE) {
3642	alias RemoveFontResourceW  RemoveFontResource;
3643}
3644else {
3645	alias RemoveFontResourceA  RemoveFontResource;
3646}
3647
3648BOOL  RoundRect(HDC hdc,int left,int top,int right,int bottom,int width,int height);
3649BOOL ResizePalette(HPALETTE hpal,UINT n);
3650
3651int  SaveDC(HDC hdc);
3652int  SelectClipRgn(HDC hdc,HRGN hrgn);
3653int  ExtSelectClipRgn(HDC hdc,HRGN hrgn,int mode);
3654int  SetMetaRgn(HDC hdc);
3655HGDIOBJ SelectObject(HDC hdc,HGDIOBJ h);
3656HPALETTE SelectPalette(HDC hdc,HPALETTE hPal,BOOL bForceBkgd);
3657COLORREF SetBkColor(HDC hdc,COLORREF color);
3658
3659COLORREF SetDCBrushColor(HDC hdc,COLORREF color);
3660COLORREF SetDCPenColor(HDC hdc,COLORREF color);
3661
3662int   SetBkMode(HDC hdc,int mode);
3663
3664LONG SetBitmapBits(
3665   HBITMAP hbm,
3666   DWORD cb,
3667    VOID *pvBits);
3668
3669UINT  SetBoundsRect(HDC hdc,RECT * lprect,UINT flags);
3670int   SetDIBits(HDC hdc,HBITMAP hbm,UINT start,UINT cLines,VOID *lpBits,BITMAPINFO * lpbmi,UINT ColorUse);
3671int   SetDIBitsToDevice(HDC hdc,int xDest,int yDest,DWORD w,DWORD h,int xSrc,
3672       int ySrc,UINT StartScan,UINT cLines,VOID * lpvBits,BITMAPINFO * lpbmi,UINT ColorUse);
3673DWORD SetMapperFlags(HDC hdc,DWORD flags);
3674int   SetGraphicsMode(HDC hdc,int iMode);
3675int   SetMapMode(HDC hdc,int iMode);
3676
3677DWORD SetLayout(HDC hdc,DWORD l);
3678DWORD GetLayout(HDC hdc);
3679
3680HMETAFILE   SetMetaFileBitsEx(UINT cbBuffer, BYTE *lpData);
3681UINT  SetPaletteEntries(  HPALETTE hpal,
3682                                           UINT iStart,
3683                                           UINT cEntries,
3684                                            PALETTEENTRY *pPalEntries);
3685COLORREF SetPixel(HDC hdc,int x,int y,COLORREF color);
3686BOOL   SetPixelV(HDC hdc,int x,int y,COLORREF color);
3687BOOL  SetPixelFormat(HDC hdc,int format,PIXELFORMATDESCRIPTOR * ppfd);
3688int   SetPolyFillMode(HDC hdc,int mode);
3689BOOL  StretchBlt(HDC hdcDest,int xDest,int yDest,int wDest,int hDest,HDC hdcSrc,int xSrc,int ySrc,int wSrc,int hSrc,DWORD rop);
3690BOOL   SetRectRgn(HRGN hrgn,int left,int top,int right,int bottom);
3691int   StretchDIBits(HDC hdc,int xDest,int yDest,int DestWidth,int DestHeight,int xSrc,int ySrc,int SrcWidth,int SrcHeight,
3692       VOID * lpBits,BITMAPINFO * lpbmi,UINT iUsage,DWORD rop);
3693int   SetROP2(HDC hdc,int rop2);
3694int   SetStretchBltMode(HDC hdc,int mode);
3695UINT  SetSystemPaletteUse(HDC hdc,UINT use);
3696int   SetTextCharacterExtra(HDC hdc,int extra);
3697COLORREF SetTextColor(HDC hdc,COLORREF color);
3698UINT  SetTextAlign(HDC hdc,UINT _align);
3699BOOL  SetTextJustification(HDC hdc,int extra,int count);
3700BOOL  UpdateColors(HDC hdc);
3701
3702typedef PVOID function(DWORD dwSize, LPVOID pGdiRef) GDIMARSHALLOC;
3703
3704typedef HRESULT function(HGDIOBJ hGdiObj,LPVOID pGdiRef,LPVOID *ppDDrawRef) DDRAWMARSHCALLBACKMARSHAL;
3705typedef HRESULT function(LPVOID pData,HDC *phdc,LPVOID *ppDDrawRef) DDRAWMARSHCALLBACKUNMARSHAL;
3706typedef HRESULT function(LPVOID pDDrawRef) DDRAWMARSHCALLBACKRELEASE;
3707
3708const auto GDIREGISTERDDRAWPACKETVERSION   = 0x1;
3709
3710struct GDIREGISTERDDRAWPACKET {
3711    DWORD                       dwSize;
3712    DWORD                       dwVersion;
3713    DDRAWMARSHCALLBACKMARSHAL   pfnDdMarshal;
3714    DDRAWMARSHCALLBACKUNMARSHAL pfnDdUnmarshal;
3715    DDRAWMARSHCALLBACKRELEASE   pfnDdRelease;
3716}
3717
3718typedef GDIREGISTERDDRAWPACKET* PGDIREGISTERDDRAWPACKET;
3719
3720BOOL      GdiRegisterDdraw(PGDIREGISTERDDRAWPACKET pPacket,GDIMARSHALLOC *ppfnGdiAlloc);
3721
3722ULONG     GdiMarshalSize();
3723VOID      GdiMarshal(DWORD dwProcessIdTo,HGDIOBJ hGdiObj,PVOID pData, ULONG ulFlags);
3724HGDIOBJ   GdiUnmarshal(PVOID pData, ULONG ulFlags);
3725
3726//
3727// image blt
3728//
3729
3730typedef USHORT COLOR16;
3731
3732struct TRIVERTEX {
3733    LONG    x;
3734    LONG    y;
3735    COLOR16 Red;
3736    COLOR16 Green;
3737    COLOR16 Blue;
3738    COLOR16 Alpha;
3739}
3740
3741typedef TRIVERTEX* PTRIVERTEX;
3742typedef TRIVERTEX* LPTRIVERTEX;
3743
3744struct GRADIENT_TRIANGLE {
3745    ULONG Vertex1;
3746    ULONG Vertex2;
3747    ULONG Vertex3;
3748}
3749
3750typedef GRADIENT_TRIANGLE* PGRADIENT_TRIANGLE;
3751typedef GRADIENT_TRIANGLE* LPGRADIENT_TRIANGLE;
3752
3753struct GRADIENT_RECT {
3754    ULONG UpperLeft;
3755    ULONG LowerRight;
3756}
3757
3758typedef GRADIENT_RECT* PGRADIENT_RECT;
3759typedef GRADIENT_RECT* LPGRADIENT_RECT;
3760
3761struct BLENDFUNCTION {
3762    BYTE   BlendOp;
3763    BYTE   BlendFlags;
3764    BYTE   SourceConstantAlpha;
3765    BYTE   AlphaFormat;
3766}
3767
3768typedef BLENDFUNCTION* PBLENDFUNCTION;
3769typedef BLENDFUNCTION* LPBLENDFUNCTION;
3770
3771//
3772// currentlly defined blend function
3773//
3774
3775const auto AC_SRC_OVER                 = 0x00;
3776
3777//
3778// alpha format flags
3779//
3780
3781const auto AC_SRC_ALPHA                = 0x01;
3782
3783BOOL AlphaBlend(HDC hdcDest,int xoriginDest,int yoriginDest,int wDest,int hDest,HDC hdcSrc,int xoriginSrc,int yoriginSrc,int wSrc,int hSrc,BLENDFUNCTION ftn);
3784
3785BOOL TransparentBlt(HDC hdcDest,int xoriginDest,int yoriginDest,int wDest,int hDest,HDC hdcSrc,
3786                                          int xoriginSrc,int yoriginSrc,int wSrc,int hSrc,UINT crTransparent);
3787
3788
3789//
3790// gradient drawing modes
3791//
3792
3793const auto GRADIENT_FILL_RECT_H    = 0x00000000;
3794const auto GRADIENT_FILL_RECT_V    = 0x00000001;
3795const auto GRADIENT_FILL_TRIANGLE  = 0x00000002;
3796const auto GRADIENT_FILL_OP_FLAG   = 0x000000ff;
3797
3798BOOL GradientFill(
3799   HDC hdc,
3800   PTRIVERTEX pVertex,
3801   ULONG nVertex,
3802   PVOID pMesh,
3803   ULONG nMesh,
3804   ULONG ulMode
3805    );
3806
3807BOOL  GdiAlphaBlend(HDC hdcDest,int xoriginDest,int yoriginDest,int wDest,int hDest,HDC hdcSrc,int xoriginSrc,int yoriginSrc,int wSrc,int hSrc,BLENDFUNCTION ftn);
3808
3809BOOL  GdiTransparentBlt(HDC hdcDest,int xoriginDest,int yoriginDest,int wDest,int hDest,HDC hdcSrc,
3810                                          int xoriginSrc,int yoriginSrc,int wSrc,int hSrc,UINT crTransparent);
3811
3812BOOL  GdiGradientFill(HDC hdc,
3813                                        PTRIVERTEX pVertex,
3814                                       ULONG nVertex,
3815                                       PVOID pMesh,
3816                                       ULONG nCount,
3817                                       ULONG ulMode);
3818
3819
3820
3821BOOL  PlayMetaFileRecord( HDC hdc,
3822	LPHANDLETABLE lpHandleTable,
3823	LPMETARECORD lpMR,
3824	UINT noObjs);
3825
3826typedef int function(HDC hdc, HANDLETABLE* lpht,METARECORD* lpMR,int nObj,LPARAM param) MFENUMPROC;
3827BOOL  EnumMetaFile(HDC hdc,HMETAFILE hmf,MFENUMPROC proc,LPARAM param);
3828
3829typedef int function (HDC hdc, HANDLETABLE* lpht,ENHMETARECORD * lpmr,int hHandles,LPARAM data) ENHMFENUMPROC;
3830
3831// Enhanced Metafile Function Declarations
3832
3833HENHMETAFILE CloseEnhMetaFile(HDC hdc);
3834HENHMETAFILE CopyEnhMetaFileA(HENHMETAFILE hEnh,LPCSTR lpFileName);
3835HENHMETAFILE CopyEnhMetaFileW(HENHMETAFILE hEnh,LPCWSTR lpFileName);
3836
3837version(UNICODE) {
3838	alias CopyEnhMetaFileW  CopyEnhMetaFile;
3839}
3840else {
3841	alias CopyEnhMetaFileA  CopyEnhMetaFile;
3842}
3843
3844HDC   CreateEnhMetaFileA(HDC hdc,LPCSTR lpFilename,RECT *lprc,LPCSTR lpDesc);
3845HDC   CreateEnhMetaFileW(HDC hdc,LPCWSTR lpFilename,RECT *lprc,LPCWSTR lpDesc);
3846
3847version(UNICODE) {
3848	alias CreateEnhMetaFileW  CreateEnhMetaFile;
3849}
3850else {
3851	alias CreateEnhMetaFileA  CreateEnhMetaFile;
3852}
3853
3854BOOL  DeleteEnhMetaFile(HENHMETAFILE hmf);
3855BOOL  EnumEnhMetaFile(HDC hdc,HENHMETAFILE hmf,ENHMFENUMPROC proc,
3856                                       LPVOID param,RECT * lpRect);
3857HENHMETAFILE  GetEnhMetaFileA(LPCSTR lpName);
3858HENHMETAFILE  GetEnhMetaFileW(LPCWSTR lpName);
3859
3860version(UNICODE) {
3861	alias GetEnhMetaFileW  GetEnhMetaFile;
3862}
3863else {
3864	alias GetEnhMetaFileA  GetEnhMetaFile;
3865}
3866
3867UINT  GetEnhMetaFileBits( HENHMETAFILE hEMF,
3868                                           UINT nSize,LPBYTE lpData);
3869UINT  GetEnhMetaFileDescriptionA( HENHMETAFILE hemf,
3870                                                   UINT cchBuffer,
3871                                                    LPSTR lpDescription);
3872UINT  GetEnhMetaFileDescriptionW( HENHMETAFILE hemf,
3873                                                   UINT cchBuffer,
3874                                                    LPWSTR lpDescription);
3875
3876version(UNICODE) {
3877	alias GetEnhMetaFileDescriptionW  GetEnhMetaFileDescription;
3878}
3879else {
3880	alias GetEnhMetaFileDescriptionA  GetEnhMetaFileDescription;
3881}
3882
3883UINT  GetEnhMetaFileHeader(   HENHMETAFILE hemf,
3884                                               UINT nSize,
3885                                                LPENHMETAHEADER lpEnhMetaHeader);
3886UINT  GetEnhMetaFilePaletteEntries(HENHMETAFILE hemf,
3887                                                   UINT nNumEntries,
3888                                                    LPPALETTEENTRY lpPaletteEntries);
3889
3890UINT  GetEnhMetaFilePixelFormat(  HENHMETAFILE hemf,
3891                                                   UINT cbBuffer,
3892                                                    PIXELFORMATDESCRIPTOR *ppfd);
3893UINT  GetWinMetaFileBits( HENHMETAFILE hemf,
3894                                           UINT cbData16,LPBYTE pData16,
3895                                           INT iMapMode,
3896                                           HDC hdcRef);
3897BOOL  PlayEnhMetaFile(HDC hdc,HENHMETAFILE hmf,RECT * lprect);
3898BOOL  PlayEnhMetaFileRecord(  HDC hdc,
3899                                                LPHANDLETABLE pht,
3900                                               ENHMETARECORD *pmr,
3901                                               UINT cht);
3902
3903HENHMETAFILE  SetEnhMetaFileBits( UINT nSize,
3904                                                    BYTE * pb);
3905
3906HENHMETAFILE  SetWinMetaFileBits( UINT nSize,
3907                                                    BYTE *lpMeta16Data,
3908                                                   HDC hdcRef,
3909                                                   METAFILEPICT *lpMFP);
3910BOOL  GdiComment(HDC hdc,UINT nSize, BYTE *lpData);
3911
3912BOOL GetTextMetricsA(HDC hdc,LPTEXTMETRICA lptm);
3913BOOL GetTextMetricsW(HDC hdc,LPTEXTMETRICW lptm);
3914
3915version(UNICODE) {
3916	alias GetTextMetricsW  GetTextMetrics;
3917}
3918else {
3919	alias GetTextMetricsA  GetTextMetrics;
3920}
3921
3922/* new GDI */
3923
3924struct DIBSECTION {
3925    BITMAP       dsBm;
3926    BITMAPINFOHEADER    dsBmih;
3927    DWORD               dsBitfields[3];
3928    HANDLE              dshSection;
3929    DWORD               dsOffset;
3930}
3931
3932typedef DIBSECTION* PDIBSECTION;
3933typedef DIBSECTION* LPDIBSECTION;
3934
3935
3936BOOL AngleArc(HDC hdc,int x,int y,DWORD r,FLOAT StartAngle,FLOAT SweepAngle);
3937BOOL PolyPolyline(HDC hdc,POINT *apt, DWORD *asz,DWORD csz);
3938BOOL GetWorldTransform(HDC hdc,LPXFORM lpxf);
3939BOOL SetWorldTransform(HDC hdc,XFORM * lpxf);
3940BOOL ModifyWorldTransform(HDC hdc,XFORM * lpxf,DWORD mode);
3941BOOL CombineTransform(LPXFORM lpxfOut,XFORM *lpxf1,XFORM *lpxf2);
3942HBITMAP CreateDIBSection(HDC hdc,BITMAPINFO *lpbmi,UINT usage,VOID **ppvBits,HANDLE hSection,DWORD offset);
3943UINT GetDIBColorTable(HDC  hdc,
3944                                       UINT iStart,
3945                                       UINT cEntries,
3946                                        RGBQUAD *prgbq);
3947UINT SetDIBColorTable(HDC  hdc,
3948                                       UINT iStart,
3949                                       UINT cEntries,
3950                                        RGBQUAD *prgbq);
3951
3952/* Flags value for COLORADJUSTMENT */
3953const auto CA_NEGATIVE                 = 0x0001;
3954const auto CA_LOG_FILTER               = 0x0002;
3955
3956/* IlluminantIndex values */
3957const auto ILLUMINANT_DEVICE_DEFAULT   = 0;
3958const auto ILLUMINANT_A                = 1;
3959const auto ILLUMINANT_B                = 2;
3960const auto ILLUMINANT_C                = 3;
3961const auto ILLUMINANT_D50              = 4;
3962const auto ILLUMINANT_D55              = 5;
3963const auto ILLUMINANT_D65              = 6;
3964const auto ILLUMINANT_D75              = 7;
3965const auto ILLUMINANT_F2               = 8;
3966const auto ILLUMINANT_MAX_INDEX        = ILLUMINANT_F2;
3967
3968const auto ILLUMINANT_TUNGSTEN         = ILLUMINANT_A;
3969const auto ILLUMINANT_DAYLIGHT         = ILLUMINANT_C;
3970const auto ILLUMINANT_FLUORESCENT      = ILLUMINANT_F2;
3971const auto ILLUMINANT_NTSC             = ILLUMINANT_C;
3972
3973/* Min and max for RedGamma, GreenGamma, BlueGamma */
3974const auto RGB_GAMMA_MIN               = 02500;
3975const auto RGB_GAMMA_MAX               = 65000;
3976
3977/* Min and max for ReferenceBlack and ReferenceWhite */
3978const auto REFERENCE_WHITE_MIN         = 6000;
3979const auto REFERENCE_WHITE_MAX         = 10000;
3980const auto REFERENCE_BLACK_MIN         = 0;
3981const auto REFERENCE_BLACK_MAX         = 4000;
3982
3983/* Min and max for Contrast, Brightness, Colorfulness, RedGreenTint */
3984const auto COLOR_ADJ_MIN               = -100;
3985const auto COLOR_ADJ_MAX               = 100;
3986
3987struct  COLORADJUSTMENT {
3988    WORD   caSize;
3989    WORD   caFlags;
3990    WORD   caIlluminantIndex;
3991    WORD   caRedGamma;
3992    WORD   caGreenGamma;
3993    WORD   caBlueGamma;
3994    WORD   caReferenceBlack;
3995    WORD   caReferenceWhite;
3996    SHORT  caContrast;
3997    SHORT  caBrightness;
3998    SHORT  caColorfulness;
3999    SHORT  caRedGreenTint;
4000}
4001
4002typedef COLORADJUSTMENT* PCOLORADJUSTMENT;
4003typedef COLORADJUSTMENT* LPCOLORADJUSTMENT;
4004
4005BOOL SetColorAdjustment(HDC hdc,COLORADJUSTMENT *lpca);
4006BOOL GetColorAdjustment(HDC hdc,LPCOLORADJUSTMENT lpca);
4007HPALETTE CreateHalftonePalette(HDC hdc);
4008
4009typedef BOOL function(HDC, int) ABORTPROC;
4010
4011struct DOCINFOA {
4012    int     cbSize;
4013    LPCSTR   lpszDocName;
4014    LPCSTR   lpszOutput;
4015    LPCSTR   lpszDatatype;
4016    DWORD    fwType;
4017}
4018
4019typedef DOCINFOA* LPDOCINFOA;
4020
4021struct DOCINFOW {
4022    int     cbSize;
4023    LPCWSTR  lpszDocName;
4024    LPCWSTR  lpszOutput;
4025    LPCWSTR  lpszDatatype;
4026    DWORD    fwType;
4027}
4028
4029typedef DOCINFOW* LPDOCINFOW;
4030
4031version(UNICODE) {
4032	typedef DOCINFOW DOCINFO;
4033	typedef LPDOCINFOW LPDOCINFO;
4034}
4035else {
4036	typedef DOCINFOA DOCINFO;
4037	typedef LPDOCINFOA LPDOCINFO;
4038}
4039
4040const auto DI_APPBANDING               = 0x00000001;
4041const auto DI_ROPS_READ_DESTINATION    = 0x00000002;
4042
4043int StartDocA(HDC hdc,DOCINFOA *lpdi);
4044int StartDocW(HDC hdc,DOCINFOW *lpdi);
4045
4046version(UNICODE) {
4047	alias StartDocW  StartDoc;
4048}
4049else {
4050	alias StartDocA  StartDoc;
4051}
4052
4053int EndDoc(HDC hdc);
4054int StartPage(HDC hdc);
4055int EndPage(HDC hdc);
4056int AbortDoc(HDC hdc);
4057int SetAbortProc(HDC hdc,ABORTPROC proc);
4058
4059BOOL AbortPath(HDC hdc);
4060BOOL ArcTo(HDC hdc,int left,int top,int right,int bottom,int xr1,int yr1,int xr2,int yr2);
4061BOOL BeginPath(HDC hdc);
4062BOOL CloseFigure(HDC hdc);
4063BOOL EndPath(HDC hdc);
4064BOOL FillPath(HDC hdc);
4065BOOL FlattenPath(HDC hdc);
4066int  GetPath(HDC hdc, LPPOINT apt, LPBYTE aj, int cpt);
4067HRGN PathToRegion(HDC hdc);
4068BOOL PolyDraw(HDC hdc, POINT * apt, BYTE * aj,int cpt);
4069BOOL SelectClipPath(HDC hdc,int mode);
4070int  SetArcDirection(HDC hdc,int dir);
4071BOOL SetMiterLimit(HDC hdc,FLOAT limit, PFLOAT old);
4072BOOL StrokeAndFillPath(HDC hdc);
4073BOOL StrokePath(HDC hdc);
4074BOOL WidenPath(HDC hdc);
4075HPEN ExtCreatePen(DWORD iPenStyle,
4076                                   DWORD cWidth,
4077                                   LOGBRUSH *plbrush,
4078                                   DWORD cStyle,
4079                                    DWORD *pstyle);
4080BOOL GetMiterLimit(HDC hdc,PFLOAT plimit);
4081int  GetArcDirection(HDC hdc);
4082
4083int   GetObjectA(HANDLE h,int c, LPVOID pv);
4084int   GetObjectW(HANDLE h,int c, LPVOID pv);
4085
4086version(UNICODE) {
4087	alias GetObjectW  GetObject;
4088}
4089else {
4090	alias GetObjectA  GetObject;
4091}
4092
4093BOOL  MoveToEx(HDC hdc,int x,int y, LPPOINT lppt);
4094BOOL  TextOutA(HDC hdc,int x,int y, LPCSTR lpString,int c);
4095BOOL  TextOutW(HDC hdc,int x,int y, LPCWSTR lpString,int c);
4096
4097version(UNICODE) {
4098	alias TextOutW  TextOut;
4099}
4100else {
4101	alias TextOutA  TextOut;
4102}
4103
4104BOOL  ExtTextOutA(HDC hdc,int x,int y,UINT options,RECT * lprect, LPCSTR lpString,UINT c, INT * lpDx);
4105BOOL  ExtTextOutW(HDC hdc,int x,int y,UINT options,RECT * lprect, LPCWSTR lpString,UINT c, INT * lpDx);
4106
4107version(UNICODE) {
4108	alias ExtTextOutW  ExtTextOut;
4109}
4110else {
4111	alias ExtTextOutA  ExtTextOut;
4112}
4113
4114BOOL  PolyTextOutA(HDC hdc, POLYTEXTA * ppt,int nstrings);
4115BOOL  PolyTextOutW(HDC hdc, POLYTEXTW * ppt,int nstrings);
4116
4117version(UNICODE) {
4118	alias PolyTextOutW  PolyTextOut;
4119}
4120else {
4121	alias PolyTextOutA  PolyTextOut;
4122}
4123
4124HRGN  CreatePolygonRgn(    POINT *pptl,
4125                                           int cPoint,
4126                                           int iMode);
4127BOOL  DPtoLP(HDC hdc, LPPOINT lppt,int c);
4128BOOL  LPtoDP(HDC hdc, LPPOINT lppt,int c);
4129BOOL  Polygon(HDC hdc, POINT *apt,int cpt);
4130BOOL  Polyline(HDC hdc, POINT *apt,int cpt);
4131
4132BOOL  PolyBezier(HDC hdc, POINT * apt,DWORD cpt);
4133BOOL  PolyBezierTo(HDC hdc, POINT * apt,DWORD cpt);
4134BOOL  PolylineTo(HDC hdc, POINT * apt,DWORD cpt);
4135
4136BOOL  SetViewportExtEx(HDC hdc,int x,int y, LPSIZE lpsz);
4137BOOL  SetViewportOrgEx(HDC hdc,int x,int y, LPPOINT lppt);
4138BOOL  SetWindowExtEx(HDC hdc,int x,int y, LPSIZE lpsz);
4139BOOL  SetWindowOrgEx(HDC hdc,int x,int y, LPPOINT lppt);
4140
4141BOOL  OffsetViewportOrgEx(HDC hdc,int x,int y, LPPOINT lppt);
4142BOOL  OffsetWindowOrgEx(HDC hdc,int x,int y, LPPOINT lppt);
4143BOOL  ScaleViewportExtEx(HDC hdc,int xn,int dx,int yn,int yd, LPSIZE lpsz);
4144BOOL  ScaleWindowExtEx(HDC hdc,int xn,int xd,int yn,int yd, LPSIZE lpsz);
4145BOOL  SetBitmapDimensionEx(HBITMAP hbm,int w,int h, LPSIZE lpsz);
4146BOOL  SetBrushOrgEx(HDC hdc,int x,int y, LPPOINT lppt);
4147
4148int   GetTextFaceA(HDC hdc,int c, LPSTR lpName);
4149int   GetTextFaceW(HDC hdc,int c, LPWSTR lpName);
4150
4151version(UNICODE) {
4152	alias GetTextFaceW  GetTextFace;
4153}
4154else {
4155	alias GetTextFaceA  GetTextFace;
4156}
4157
4158const auto FONTMAPPER_MAX = 10;
4159
4160struct KERNINGPAIR {
4161   WORD wFirst;
4162   WORD wSecond;
4163   int  iKernAmount;
4164}
4165
4166typedef KERNINGPAIR* LPKERNINGPAIR;
4167
4168DWORD GetKerningPairsA(   HDC hdc,
4169                                           DWORD nPairs,
4170                                            LPKERNINGPAIR   lpKernPair);
4171DWORD GetKerningPairsW(   HDC hdc,
4172                                           DWORD nPairs,
4173                                            LPKERNINGPAIR   lpKernPair);
4174version(UNICODE) {
4175	alias GetKerningPairsW  GetKerningPairs;
4176}
4177else {
4178	alias GetKerningPairsA  GetKerningPairs;
4179}
4180
4181
4182BOOL  GetDCOrgEx(HDC hdc,LPPOINT lppt);
4183BOOL  FixBrushOrgEx(HDC hdc,int x,int y, LPPOINT ptl);
4184BOOL  UnrealizeObject(HGDIOBJ h);
4185
4186BOOL  GdiFlush();
4187DWORD GdiSetBatchLimit(DWORD dw);
4188DWORD GdiGetBatchLimit();
4189
4190const auto ICM_OFF               = 1;
4191const auto ICM_ON                = 2;
4192const auto ICM_QUERY             = 3;
4193const auto ICM_DONE_OUTSIDEDC    = 4;
4194
4195typedef int function(LPSTR, LPARAM) ICMENUMPROCA;
4196typedef int function(LPWSTR, LPARAM) ICMENUMPROCW;
4197
4198version(UNICODE) {
4199	alias ICMENUMPROCW  ICMENUMPROC;
4200}
4201else {
4202	alias ICMENUMPROCA  ICMENUMPROC;
4203}
4204
4205int         SetICMMode(HDC hdc,int mode);
4206BOOL        CheckColorsInGamut(   HDC hdc,
4207                                                    LPRGBTRIPLE lpRGBTriple,
4208                                                    LPVOID dlpBuffer,
4209                                                   DWORD nCount);
4210
4211HCOLORSPACE GetColorSpace(HDC hdc);
4212BOOL        GetLogColorSpaceA(HCOLORSPACE hColorSpace,
4213                                                LPLOGCOLORSPACEA lpBuffer,
4214                                               DWORD nSize);
4215BOOL        GetLogColorSpaceW(HCOLORSPACE hColorSpace,
4216                                                LPLOGCOLORSPACEW lpBuffer,
4217                                               DWORD nSize);
4218version(UNICODE) {
4219	alias GetLogColorSpaceW  GetLogColorSpace;
4220}
4221else {
4222	alias GetLogColorSpaceA  GetLogColorSpace;
4223}
4224
4225HCOLORSPACE CreateColorSpaceA(LPLOGCOLORSPACEA lplcs);
4226HCOLORSPACE CreateColorSpaceW(LPLOGCOLORSPACEW lplcs);
4227
4228version(UNICODE) {
4229	alias CreateColorSpaceW  CreateColorSpace;
4230}
4231else {
4232	alias CreateColorSpaceA  CreateColorSpace;
4233}
4234
4235HCOLORSPACE SetColorSpace(HDC hdc,HCOLORSPACE hcs);
4236BOOL        DeleteColorSpace(HCOLORSPACE hcs);
4237BOOL        GetICMProfileA(   HDC hdc,
4238                                               LPDWORD pBufSize,
4239                                                LPSTR pszFilename);
4240BOOL        GetICMProfileW(   HDC hdc,
4241                                               LPDWORD pBufSize,
4242                                                LPWSTR pszFilename);
4243
4244version(UNICODE) {
4245	alias GetICMProfileW  GetICMProfile;
4246}
4247else {
4248	alias GetICMProfileA  GetICMProfile;
4249}
4250
4251BOOL        SetICMProfileA(HDC hdc,LPSTR lpFileName);
4252BOOL        SetICMProfileW(HDC hdc,LPWSTR lpFileName);
4253
4254version(UNICODE) {
4255	alias SetICMProfileW  SetICMProfile;
4256}
4257else {
4258	alias SetICMProfileA  SetICMProfile;
4259}
4260
4261BOOL        GetDeviceGammaRamp(HDC hdc, LPVOID lpRamp);
4262BOOL        SetDeviceGammaRamp(HDC hdc, LPVOID lpRamp);
4263BOOL        ColorMatchToTarget(HDC hdc,HDC hdcTarget,DWORD action);
4264int         EnumICMProfilesA(HDC hdc,ICMENUMPROCA proc,LPARAM param);
4265int         EnumICMProfilesW(HDC hdc,ICMENUMPROCW proc,LPARAM param);
4266
4267version(UNICODE) {
4268	alias EnumICMProfilesW  EnumICMProfilesW;
4269}
4270else {
4271	alias EnumICMProfilesA  EnumICMProfilesA;
4272}
4273
4274// The Win95 update API UpdateICMRegKeyA is deprecated to set last error to ERROR_NOT_SUPPORTED and return FALSE
4275BOOL        UpdateICMRegKeyA(DWORD reserved,LPSTR lpszCMID,LPSTR lpszFileName,UINT command);
4276// The Win95 update API UpdateICMRegKeyW is deprecated to set last error to ERROR_NOT_SUPPORTED and return FALSE
4277BOOL        UpdateICMRegKeyW(DWORD reserved,LPWSTR lpszCMID,LPWSTR lpszFileName,UINT command);
4278
4279version(UNICODE) {
4280	alias UpdateICMRegKeyW  UpdateICMRegKey;
4281}
4282else {
4283	alias UpdateICMRegKeyA  UpdateICMRegKey;
4284}
4285BOOL        ColorCorrectPalette(HDC hdc,HPALETTE hPal,DWORD deFirst,DWORD num);
4286
4287// Enhanced metafile constants.
4288const auto ENHMETA_SIGNATURE       = 0x20454D46;
4289
4290// Stock object flag used in the object handle index in the enhanced
4291// metafile records.
4292// E.g. The object handle index (META_STOCK_OBJECT | BLACK_BRUSH)
4293// represents the stock object BLACK_BRUSH.
4294
4295const auto ENHMETA_STOCK_OBJECT    = 0x80000000;
4296
4297// Enhanced metafile record types.
4298
4299const auto EMR_HEADER                      = 1;
4300const auto EMR_POLYBEZIER                  = 2;
4301const auto EMR_POLYGON                     = 3;
4302const auto EMR_POLYLINE                    = 4;
4303const auto EMR_POLYBEZIERTO                = 5;
4304const auto EMR_POLYLINETO                  = 6;
4305const auto EMR_POLYPOLYLINE                = 7;
4306const auto EMR_POLYPOLYGON                 = 8;
4307const auto EMR_SETWINDOWEXTEX              = 9;
4308const auto EMR_SETWINDOWORGEX              = 10;
4309const auto EMR_SETVIEWPORTEXTEX            = 11;
4310const auto EMR_SETVIEWPORTORGEX            = 12;
4311const auto EMR_SETBRUSHORGEX               = 13;
4312const auto EMR_EOF                         = 14;
4313const auto EMR_SETPIXELV                   = 15;
4314const auto EMR_SETMAPPERFLAGS              = 16;
4315const auto EMR_SETMAPMODE                  = 17;
4316const auto EMR_SETBKMODE                   = 18;
4317const auto EMR_SETPOLYFILLMODE             = 19;
4318const auto EMR_SETROP2                     = 20;
4319const auto EMR_SETSTRETCHBLTMODE           = 21;
4320const auto EMR_SETTEXTALIGN                = 22;
4321const auto EMR_SETCOLORADJUSTMENT          = 23;
4322const auto EMR_SETTEXTCOLOR                = 24;
4323const auto EMR_SETBKCOLOR                  = 25;
4324const auto EMR_OFFSETCLIPRGN               = 26;
4325const auto EMR_MOVETOEX                    = 27;
4326const auto EMR_SETMETARGN                  = 28;
4327const auto EMR_EXCLUDECLIPRECT             = 29;
4328const auto EMR_INTERSECTCLIPRECT           = 30;
4329const auto EMR_SCALEVIEWPORTEXTEX          = 31;
4330const auto EMR_SCALEWINDOWEXTEX            = 32;
4331const auto EMR_SAVEDC                      = 33;
4332const auto EMR_RESTOREDC                   = 34;
4333const auto EMR_SETWORLDTRANSFORM           = 35;
4334const auto EMR_MODIFYWORLDTRANSFORM        = 36;
4335const auto EMR_SELECTOBJECT                = 37;
4336const auto EMR_CREATEPEN                   = 38;
4337const auto EMR_CREATEBRUSHINDIRECT         = 39;
4338const auto EMR_DELETEOBJECT                = 40;
4339const auto EMR_ANGLEARC                    = 41;
4340const auto EMR_ELLIPSE                     = 42;
4341const auto EMR_RECTANGLE                   = 43;
4342const auto EMR_ROUNDRECT                   = 44;
4343const auto EMR_ARC                         = 45;
4344const auto EMR_CHORD                       = 46;
4345const auto EMR_PIE                         = 47;
4346const auto EMR_SELECTPALETTE               = 48;
4347const auto EMR_CREATEPALETTE               = 49;
4348const auto EMR_SETPALETTEENTRIES           = 50;
4349const auto EMR_RESIZEPALETTE               = 51;
4350const auto EMR_REALIZEPALETTE              = 52;
4351const auto EMR_EXTFLOODFILL                = 53;
4352const auto EMR_LINETO                      = 54;
4353const auto EMR_ARCTO                       = 55;
4354const auto EMR_POLYDRAW                    = 56;
4355const auto EMR_SETARCDIRECTION             = 57;
4356const auto EMR_SETMITERLIMIT               = 58;
4357const auto EMR_BEGINPATH                   = 59;
4358const auto EMR_ENDPATH                     = 60;
4359const auto EMR_CLOSEFIGURE                 = 61;
4360const auto EMR_FILLPATH                    = 62;
4361const auto EMR_STROKEANDFILLPATH           = 63;
4362const auto EMR_STROKEPATH                  = 64;
4363const auto EMR_FLATTENPATH                 = 65;
4364const auto EMR_WIDENPATH                   = 66;
4365const auto EMR_SELECTCLIPPATH              = 67;
4366const auto EMR_ABORTPATH                   = 68;
4367
4368const auto EMR_GDICOMMENT                  = 70;
4369const auto EMR_FILLRGN                     = 71;
4370const auto EMR_FRAMERGN                    = 72;
4371const auto EMR_INVERTRGN                   = 73;
4372const auto EMR_PAINTRGN                    = 74;
4373const auto EMR_EXTSELECTCLIPRGN            = 75;
4374const auto EMR_BITBLT                      = 76;
4375const auto EMR_STRETCHBLT                  = 77;
4376const auto EMR_MASKBLT                     = 78;
4377const auto EMR_PLGBLT                      = 79;
4378const auto EMR_SETDIBITSTODEVICE           = 80;
4379const auto EMR_STRETCHDIBITS               = 81;
4380const auto EMR_EXTCREATEFONTINDIRECTW      = 82;
4381const auto EMR_EXTTEXTOUTA                 = 83;
4382const auto EMR_EXTTEXTOUTW                 = 84;
4383const auto EMR_POLYBEZIER16                = 85;
4384const auto EMR_POLYGON16                   = 86;
4385const auto EMR_POLYLINE16                  = 87;
4386const auto EMR_POLYBEZIERTO16              = 88;
4387const auto EMR_POLYLINETO16                = 89;
4388const auto EMR_POLYPOLYLINE16              = 90;
4389const auto EMR_POLYPOLYGON16               = 91;
4390const auto EMR_POLYDRAW16                  = 92;
4391const auto EMR_CREATEMONOBRUSH             = 93;
4392const auto EMR_CREATEDIBPATTERNBRUSHPT     = 94;
4393const auto EMR_EXTCREATEPEN                = 95;
4394const auto EMR_POLYTEXTOUTA                = 96;
4395const auto EMR_POLYTEXTOUTW                = 97;
4396
4397const auto EMR_SETICMMODE                  = 98;
4398const auto EMR_CREATECOLORSPACE            = 99;
4399const auto EMR_SETCOLORSPACE              = 100;
4400const auto EMR_DELETECOLORSPACE           = 101;
4401const auto EMR_GLSRECORD                  = 102;
4402const auto EMR_GLSBOUNDEDRECORD           = 103;
4403const auto EMR_PIXELFORMAT                = 104;
4404
4405const auto EMR_RESERVED_105               = 105;
4406const auto EMR_RESERVED_106               = 106;
4407const auto EMR_RESERVED_107               = 107;
4408const auto EMR_RESERVED_108               = 108;
4409const auto EMR_RESERVED_109               = 109;
4410const auto EMR_RESERVED_110               = 110;
4411const auto EMR_COLORCORRECTPALETTE        = 111;
4412const auto EMR_SETICMPROFILEA             = 112;
4413const auto EMR_SETICMPROFILEW             = 113;
4414const auto EMR_ALPHABLEND                 = 114;
4415const auto EMR_SETLAYOUT                  = 115;
4416const auto EMR_TRANSPARENTBLT             = 116;
4417const auto EMR_RESERVED_117               = 117;
4418const auto EMR_GRADIENTFILL               = 118;
4419const auto EMR_RESERVED_119               = 119;
4420const auto EMR_RESERVED_120               = 120;
4421const auto EMR_COLORMATCHTOTARGETW        = 121;
4422const auto EMR_CREATECOLORSPACEW          = 122;
4423
4424const auto EMR_MIN                          = 1;
4425
4426const auto EMR_MAX                        = 122;
4427
4428// Base record type for the enhanced metafile.
4429
4430struct EMR {
4431    DWORD   iType;              // Enhanced metafile record type
4432    DWORD   nSize;              // Length of the record in bytes.
4433                                // This must be a multiple of 4.
4434}
4435
4436typedef EMR* PEMR;
4437typedef EMR* LPEMR;
4438
4439// Base text record type for the enhanced metafile.
4440
4441struct EMRTEXT {
4442    POINTL  ptlReference;
4443    DWORD   nChars;
4444    DWORD   offString;          // Offset to the string
4445    DWORD   fOptions;
4446    RECTL   rcl;
4447    DWORD   offDx;              // Offset to the inter-character spacing array.
4448                                // This is always given.
4449}
4450
4451typedef EMRTEXT* PEMRTEXT;
4452typedef EMRTEXT* LPEMRTEXT;
4453
4454// Record structures for the enhanced metafile.
4455
4456struct ABORTPATH {
4457    EMR     emr;
4458}
4459
4460typedef ABORTPATH EMRABORTPATH;
4461typedef ABORTPATH* PEMRABORTPATH;
4462typedef ABORTPATH* LPEMRABORTPATH;
4463
4464typedef ABORTPATH EMRBEGINPATH;
4465typedef ABORTPATH* PEMRBEGINPATH;
4466typedef ABORTPATH* LPEMRBEGINPATH;
4467
4468typedef ABORTPATH EMRENDPATH;
4469typedef ABORTPATH* PEMRENDPATH;
4470typedef ABORTPATH* LPEMRENDPATH;
4471
4472typedef ABORTPATH EMRCLOSEFIGURE;
4473typedef ABORTPATH* PEMRCLOSEFIGURE;
4474typedef ABORTPATH* LPEMRCLOSEFIGURE;
4475
4476typedef ABORTPATH EMRFLATTENPATH;
4477typedef ABORTPATH* PEMRFLATTENPATH;
4478typedef ABORTPATH* LPEMRFLATTENPATH;
4479
4480typedef ABORTPATH EMRWIDENPATH;
4481typedef ABORTPATH* PEMRWIDENPATH;
4482typedef ABORTPATH* LPEMRWIDENPATH;
4483
4484typedef ABORTPATH EMRSETMETARGN;
4485typedef ABORTPATH* PEMRSETMETARGN;
4486typedef ABORTPATH* LPEMRSETMETARGN;
4487
4488typedef ABORTPATH EMRSAVEDC;
4489typedef ABORTPATH* PEMRSAVEDC;
4490typedef ABORTPATH* LPEMRSAVEDC;
4491
4492typedef ABORTPATH EMRREALIZEPALETTE;
4493typedef ABORTPATH* PEMRREALIZEPALETTE;
4494typedef ABORTPATH* LPEMRREALIZEPALETTE;
4495
4496struct EMRSELECTCLIPPATH {
4497    EMR     emr;
4498    DWORD   iMode;
4499}
4500
4501typedef EMRSELECTCLIPPATH* PEMRSELECTCLIPPATH;
4502typedef EMRSELECTCLIPPATH* LPEMRSELECTCLIPPATH;
4503
4504typedef EMRSELECTCLIPPATH EMRSETBKMODE;
4505typedef EMRSELECTCLIPPATH* PEMRSETBKMODE;
4506typedef EMRSELECTCLIPPATH* LPEMRSETBKMODE;
4507
4508typedef EMRSELECTCLIPPATH EMRSETLAYOUT;
4509typedef EMRSELECTCLIPPATH* PEMRSETLAYOUT;
4510typedef EMRSELECTCLIPPATH* LPEMRSETLAYOUT;
4511
4512typedef EMRSELECTCLIPPATH EMRSETPOLYFILLMODE;
4513typedef EMRSELECTCLIPPATH* PEMRSETPOLYFILLMODE;
4514typedef EMRSELECTCLIPPATH* LPEMRSETPOLYFILLMODE;
4515
4516typedef EMRSELECTCLIPPATH EMRSETROP2;
4517typedef EMRSELECTCLIPPATH* PEMRSETROP2;
4518typedef EMRSELECTCLIPPATH* LPEMRSETROP2;
4519
4520typedef EMRSELECTCLIPPATH EMRSETSTRETCHBLTMODE;
4521typedef EMRSELECTCLIPPATH* PEMRSETSTRETCHBLTMODE;
4522typedef EMRSELECTCLIPPATH* LPEMRSETSTRETCHBLTMODE;
4523
4524typedef EMRSELECTCLIPPATH EMRSETICMMODE;
4525typedef EMRSELECTCLIPPATH* PEMRSETICMMODE;
4526typedef EMRSELECTCLIPPATH* LPEMRSETICMMODE;
4527
4528typedef EMRSELECTCLIPPATH EMRSETTEXTALIGN;
4529typedef EMRSELECTCLIPPATH* PEMRSETTEXTALIGN;
4530typedef EMRSELECTCLIPPATH* LPEMRSETTEXTALIGN;
4531
4532struct EMRSETMITERLIMIT {
4533    EMR     emr;
4534    FLOAT   eMiterLimit;
4535}
4536
4537typedef EMRSETMITERLIMIT* PEMRSETMITERLIMIT;
4538typedef EMRSETMITERLIMIT* LPEMRSETMITERLIMIT;
4539
4540struct EMRRESTOREDC {
4541    EMR     emr;
4542    LONG    iRelative;          // Specifies a relative instance
4543}
4544
4545typedef EMRRESTOREDC* PEMRRESTOREDC;
4546typedef EMRRESTOREDC* LPEMRRESTOREDC;
4547
4548struct EMRSETARCDIRECTION {
4549    EMR     emr;
4550    DWORD   iArcDirection;      // Specifies the arc direction in the
4551                                // advanced graphics mode.
4552}
4553
4554typedef EMRSETARCDIRECTION* PEMRSETARCDIRECTION;
4555typedef EMRSETARCDIRECTION* LPEMRSETARCDIRECTION;
4556
4557struct EMRSETMAPPERFLAGS {
4558    EMR     emr;
4559    DWORD   dwFlags;
4560}
4561
4562typedef EMRSETMAPPERFLAGS* PEMRSETMAPPERFLAGS;
4563typedef EMRSETMAPPERFLAGS* LPEMRSETMAPPERFLAGS;
4564
4565struct EMRSETTEXTCOLOR {
4566    EMR     emr;
4567    COLORREF crColor;
4568}
4569
4570typedef EMRSETTEXTCOLOR EMRSETBKCOLOR;
4571typedef EMRSETTEXTCOLOR* PEMRSETBKCOLOR;
4572typedef EMRSETTEXTCOLOR* LPEMRSETBKCOLOR;
4573
4574typedef EMRSETTEXTCOLOR* PEMRSETTEXTCOLOR;
4575typedef EMRSETTEXTCOLOR* LPEMRSETTEXTCOLOR;
4576
4577struct EMRSELECTOBJECT {
4578    EMR     emr;
4579    DWORD   ihObject;           // Object handle index
4580}
4581
4582typedef EMRSELECTOBJECT* PEMRSELECTOBJECT;
4583typedef EMRSELECTOBJECT* LPEMRSELECTOBJECT;
4584
4585typedef EMRSELECTOBJECT EMRDELETEOBJECT;
4586typedef EMRSELECTOBJECT* PEMRDELETEOBJECT;
4587typedef EMRSELECTOBJECT* LPEMRDELETEOBJECT;
4588
4589struct EMRSELECTPALETTE {
4590    EMR     emr;
4591    DWORD   ihPal;              // Palette handle index, background mode only
4592}
4593
4594typedef EMRSELECTPALETTE* PEMRSELECTPALETTE;
4595typedef EMRSELECTPALETTE* LPEMRSELECTPALETTE;
4596
4597struct EMRRESIZEPALETTE {
4598    EMR     emr;
4599    DWORD   ihPal;              // Palette handle index
4600    DWORD   cEntries;
4601}
4602
4603typedef EMRRESIZEPALETTE* PEMRRESIZEPALETTE;
4604typedef EMRRESIZEPALETTE* LPEMRRESIZEPALETTE;
4605
4606struct EMRSETPALETTEENTRIES {
4607    EMR     emr;
4608    DWORD   ihPal;              // Palette handle index
4609    DWORD   iStart;
4610    DWORD   cEntries;
4611    PALETTEENTRY[1] aPalEntries;// The peFlags fields do not contain any flags
4612}
4613
4614typedef EMRSETPALETTEENTRIES* PEMRSETPALETTEENTRIES;
4615typedef EMRSETPALETTEENTRIES* LPEMRSETPALETTEENTRIES;
4616
4617struct EMRSETCOLORADJUSTMENT {
4618    EMR     emr;
4619    COLORADJUSTMENT ColorAdjustment;
4620}
4621
4622typedef EMRSETCOLORADJUSTMENT* PEMRSETCOLORADJUSTMENT;
4623typedef EMRSETCOLORADJUSTMENT* LPEMRSETCOLORADJUSTMENT;
4624
4625struct EMRGDICOMMENT {
4626    EMR     emr;
4627    DWORD   cbData;             // Size of data in bytes
4628    BYTE[1]    Data;
4629}
4630
4631typedef EMRGDICOMMENT* PEMRGDICOMMENT;
4632typedef EMRGDICOMMENT* LPEMRGDICOMMENT;
4633
4634struct EMREOF {
4635    EMR     emr;
4636    DWORD   nPalEntries;        // Number of palette entries
4637    DWORD   offPalEntries;      // Offset to the palette entries
4638    DWORD   nSizeLast;          // Same as nSize and must be the last DWORD
4639                                // of the record.  The palette entries,
4640                                // if exist, precede this field.
4641}
4642
4643typedef EMREOF* PEMREOF;
4644typedef EMREOF* LPEMREOF;
4645
4646struct EMRLINETO {
4647    EMR     emr;
4648    POINTL  ptl;
4649}
4650
4651typedef EMRLINETO* PEMRLINETO;
4652typedef EMRLINETO* LPEMRLINETO;
4653
4654typedef EMRLINETO EMRLINETOEX;
4655typedef EMRLINETO* PEMRLINETOEX;
4656typedef EMRLINETO* LPEMRLINETOEX;
4657
4658struct EMROFFSETCLIPRGN {
4659    EMR     emr;
4660    POINTL  ptlOffset;
4661}
4662
4663typedef EMROFFSETCLIPRGN* PEMROFFSETCLIPRGN;
4664
4665struct EMRFILLPATH {
4666    EMR     emr;
4667    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
4668}
4669
4670typedef EMRFILLPATH* PEMRFILLPATH;
4671typedef EMRFILLPATH* LPEMRFILLPATH;
4672
4673typedef EMRFILLPATH EMRSTROKEANDFILLPATH;
4674typedef EMRFILLPATH* PEMRSTROKEANDFILLPATH;
4675typedef EMRFILLPATH* LPEMRSTROKEANDFILLPATH;
4676
4677typedef EMRFILLPATH EMRSTROKEPATH;
4678typedef EMRFILLPATH* PEMRSTROKEPATH;
4679typedef EMRFILLPATH* LPEMRSTROKEPATH;
4680
4681struct EMREXCLUDECLIPRECT {
4682    EMR     emr;
4683    RECTL   rclClip;
4684}
4685
4686typedef EMREXCLUDECLIPRECT* PEMREXCLUDECLIPRECT;
4687typedef EMREXCLUDECLIPRECT* LPEMREXCLUDECLIPRECT;
4688
4689typedef EMREXCLUDECLIPRECT EMRINTERSECTCLIPRECT;
4690typedef EMREXCLUDECLIPRECT* PEMRINTERSECTCLIPRECT;
4691typedef EMREXCLUDECLIPRECT* LPEMRINTERSECTCLIPRECT;
4692
4693struct EMRSETVIEWPORTORGEX {
4694    EMR     emr;
4695    POINTL  ptlOrigin;
4696}
4697
4698typedef EMRSETVIEWPORTORGEX* PEMRSETVIEWPORTORGEX;
4699typedef EMRSETVIEWPORTORGEX* LPEMRSETVIEWPORTORGEX;
4700
4701typedef EMRSETVIEWPORTORGEX EMRSETWINDOWORGEX;
4702typedef EMRSETVIEWPORTORGEX* PEMRSETWINDOWORGEX;
4703typedef EMRSETVIEWPORTORGEX* LPEMRSETWINDOWORGEX;
4704
4705typedef EMRSETVIEWPORTORGEX EMRSETBRUSHORGEX;
4706typedef EMRSETVIEWPORTORGEX* PEMRSETBRUSHORGEX;
4707typedef EMRSETVIEWPORTORGEX* LPEMRSETBRUSHORGEX;
4708
4709struct EMRSETVIEWPORTEXTEX {
4710    EMR     emr;
4711    SIZEL   szlExtent;
4712}
4713
4714typedef EMRSETVIEWPORTEXTEX* PEMRSETVIEWPORTEXTEX;
4715typedef EMRSETVIEWPORTEXTEX* LPEMRSETVIEWPORTEXTEX;
4716
4717typedef EMRSETVIEWPORTORGEX EMRSETWINDOWEXTEX;
4718typedef EMRSETVIEWPORTORGEX* PEMRSETWINDOWEXTEX;
4719typedef EMRSETVIEWPORTORGEX* LPEMRSETWINDOWEXTEX;
4720
4721struct EMRSCALEVIEWPORTEXTEX {
4722    EMR     emr;
4723    LONG    xNum;
4724    LONG    xDenom;
4725    LONG    yNum;
4726    LONG    yDenom;
4727}
4728
4729typedef EMRSCALEVIEWPORTEXTEX* PEMRSCALEVIEWPORTEXTEX;
4730typedef EMRSCALEVIEWPORTEXTEX* LPEMRSCALEVIEWPORTEXTEX;
4731
4732typedef EMRSCALEVIEWPORTEXTEX EMRSCALEWINDOWEXTEX;
4733typedef EMRSCALEVIEWPORTEXTEX* PEMRSCALEWINDOWEXTEX;
4734typedef EMRSCALEVIEWPORTEXTEX* LPEMRSCALEWINDOWEXTEX;
4735
4736struct EMRSETWORLDTRANSFORM {
4737    EMR     emr;
4738    XFORM   xform;
4739}
4740
4741typedef EMRSETWORLDTRANSFORM* PEMRSETWORLDTRANSFORM;
4742typedef EMRSETWORLDTRANSFORM* LPEMRSETWORLDTRANSFORM;
4743
4744struct EMRMODIFYWORLDTRANSFORM {
4745    EMR     emr;
4746    XFORM   xform;
4747    DWORD   iMode;
4748}
4749
4750typedef EMRMODIFYWORLDTRANSFORM* PEMRMODIFYWORLDTRANSFORM;
4751
4752struct EMRSETPIXELV {
4753    EMR     emr;
4754    POINTL  ptlPixel;
4755    COLORREF crColor;
4756}
4757
4758typedef EMRSETPIXELV* PEMRSETPIXELV;
4759
4760struct EMREXTFLOODFILL {
4761    EMR     emr;
4762    POINTL  ptlStart;
4763    COLORREF crColor;
4764    DWORD   iMode;
4765}
4766
4767typedef EMREXTFLOODFILL* PEMREXTFLOODFILL;
4768
4769struct EMRELLIPSE {
4770    EMR     emr;
4771    RECTL   rclBox;             // Inclusive-inclusive bounding rectangle
4772}
4773
4774typedef EMRELLIPSE* PEMRELLIPSE;
4775typedef EMRELLIPSE* LPEMRELLIPSE;
4776
4777typedef EMRELLIPSE EMRRECTANGLE;
4778typedef EMRELLIPSE* PEMRRECTANGLE;
4779typedef EMRELLIPSE* LPEMRRECTANGLE;
4780
4781struct EMRROUNDRECT {
4782    EMR     emr;
4783    RECTL   rclBox;             // Inclusive-inclusive bounding rectangle
4784    SIZEL   szlCorner;
4785}
4786
4787typedef EMRROUNDRECT* PEMRROUNDRECT;
4788
4789struct EMRARC {
4790    EMR     emr;
4791    RECTL   rclBox;             // Inclusive-inclusive bounding rectangle
4792    POINTL  ptlStart;
4793    POINTL  ptlEnd;
4794}
4795
4796typedef EMRARC* PEMRARC;
4797typedef EMRARC* LPEMRARC;
4798
4799typedef EMRARC EMRARCTO;
4800typedef EMRARC* PEMRARCTO;
4801typedef EMRARC* LPEMRARCTO;
4802
4803typedef EMRARC EMRCHORD;
4804typedef EMRARC* PEMRCHORD;
4805typedef EMRARC* LPEMRCHORD;
4806
4807typedef EMRARC EMRPIE;
4808typedef EMRARC* PEMRPIE;
4809typedef EMRARC* LPEMRPIE;
4810
4811struct EMRANGLEARC {
4812    EMR     emr;
4813    POINTL  ptlCenter;
4814    DWORD   nRadius;
4815    FLOAT   eStartAngle;
4816    FLOAT   eSweepAngle;
4817}
4818
4819typedef EMRANGLEARC* PEMRANGLEARC;
4820
4821struct EMRPOLYLINE {
4822    EMR     emr;
4823    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
4824    DWORD   cptl;
4825    POINTL[1]  aptl;
4826}
4827
4828typedef EMRPOLYLINE* PEMRPOLYLINE;
4829typedef EMRPOLYLINE* LPEMRPOLYLINE;
4830
4831typedef EMRPOLYLINE EMRPOLYBEZIER;
4832typedef EMRPOLYLINE* PEMRPOLYBEZIER;
4833typedef EMRPOLYLINE* LPEMRPOLYBEZIER;
4834
4835typedef EMRPOLYLINE EMRPOLYGON;
4836typedef EMRPOLYLINE* PEMRPOLYGON;
4837typedef EMRPOLYLINE* LPEMRPOLYGON;
4838
4839typedef EMRPOLYLINE EMRPOLYBEZIERTO;
4840typedef EMRPOLYLINE* PEMRPOLYBEZIERTO;
4841typedef EMRPOLYLINE* LPEMRPOLYBEZIERTO;
4842
4843typedef EMRPOLYLINE EMRPOLYLINETO;
4844typedef EMRPOLYLINE* PEMRPOLYLINETO;
4845typedef EMRPOLYLINE* LPEMRPOLYLINETO;
4846
4847struct EMRPOLYLINE16 {
4848    EMR     emr;
4849    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
4850    DWORD   cpts;
4851    POINTS[1]  apts;
4852}
4853
4854typedef EMRPOLYLINE16* PEMRPOLYLINE16;
4855typedef EMRPOLYLINE16* LPEMRPOLYLINE16;
4856
4857typedef EMRPOLYLINE16 EMRPOLYBEZIER16;
4858typedef EMRPOLYLINE16* PEMRPOLYBEZIER16;
4859typedef EMRPOLYLINE16* LPEMRPOLYBEZIER16;
4860
4861typedef EMRPOLYLINE16 EMRPOLYGON16;
4862typedef EMRPOLYLINE16* PEMRPOLYGON16;
4863typedef EMRPOLYLINE16* LPEMRPOLYGON16;
4864
4865typedef EMRPOLYLINE16 EMRPOLYBEZIERTO16;
4866typedef EMRPOLYLINE16* PEMRPOLYBEZIERTO16;
4867typedef EMRPOLYLINE16* LPEMRPOLYBEZIERTO16;
4868
4869typedef EMRPOLYLINE16 EMRPOLYLINETO16;
4870typedef EMRPOLYLINE16* PEMRPOLYLINETO16;
4871typedef EMRPOLYLINE16* LPEMRPOLYLINETO16;
4872
4873struct EMRPOLYDRAW {
4874    EMR     emr;
4875    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
4876    DWORD   cptl;               // Number of points
4877    POINTL[1]  aptl;            // Array of points
4878    BYTE[1]    abTypes;         // Array of point types
4879}
4880
4881typedef EMRPOLYDRAW* PEMRPOLYDRAW;
4882typedef EMRPOLYDRAW* LPEMRPOLYDRAW;
4883
4884struct EMRPOLYDRAW16 {
4885    EMR     emr;
4886    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
4887    DWORD   cpts;               // Number of points
4888    POINTS[1]  apts;            // Array of points
4889    BYTE[1]   abTypes;         // Array of point types
4890}
4891
4892typedef EMRPOLYDRAW16* PEMRPOLYDRAW16;
4893typedef EMRPOLYDRAW16* LPEMRPOLYDRAW16;
4894
4895struct EMRPOLYPOLYLINE {
4896    EMR     emr;
4897    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
4898    DWORD   nPolys;             // Number of polys
4899    DWORD   cptl;               // Total number of points in all polys
4900    DWORD[1]   aPolyCounts;     // Array of point counts for each poly
4901    POINTL[1]  aptl;            // Array of points
4902}
4903
4904typedef EMRPOLYPOLYLINE* PEMRPOLYPOLYLINE;
4905typedef EMRPOLYPOLYLINE* LPEMRPOLYPOLYLINE;
4906
4907typedef EMRPOLYPOLYLINE EMRPOLYPOLYGON;
4908typedef EMRPOLYPOLYLINE* PEMRPOLYPOLYGON;
4909typedef EMRPOLYPOLYLINE* LPEMRPOLYPOLYGON;
4910
4911struct EMRPOLYPOLYLINE16 {
4912    EMR     emr;
4913    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
4914    DWORD   nPolys;             // Number of polys
4915    DWORD   cpts;               // Total number of points in all polys
4916    DWORD[1]   aPolyCounts;     // Array of point counts for each poly
4917    POINTS[1]  apts;            // Array of points
4918}
4919
4920typedef EMRPOLYPOLYLINE16* PEMRPOLYPOLYLINE16;
4921typedef EMRPOLYPOLYLINE16* LPEMRPOLYPOLYLINE16;
4922
4923typedef EMRPOLYPOLYLINE16 EMRPOLYPOLYGON16;
4924typedef EMRPOLYPOLYLINE16* PEMRPOLYPOLYGON16;
4925typedef EMRPOLYPOLYLINE16* LPEMRPOLYPOLYGON16;
4926
4927struct EMRINVERTRGN {
4928    EMR     emr;
4929    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
4930    DWORD   cbRgnData;          // Size of region data in bytes
4931    BYTE[1]    RgnData;
4932}
4933
4934typedef EMRINVERTRGN* PEMRINVERTRGN;
4935typedef EMRINVERTRGN* LPEMRINVERTRGN;
4936
4937typedef EMRINVERTRGN EMRPAINTRGN;
4938typedef EMRINVERTRGN* PEMRPAINTRGN;
4939typedef EMRINVERTRGN* LPEMRPAINTRGN;
4940
4941struct EMRFILLRGN {
4942    EMR     emr;
4943    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
4944    DWORD   cbRgnData;          // Size of region data in bytes
4945    DWORD   ihBrush;            // Brush handle index
4946    BYTE[1]    RgnData;
4947}
4948
4949typedef EMRFILLRGN* PEMRFILLRGN;
4950typedef EMRFILLRGN* LPEMRFILLRGN;
4951
4952struct EMRFRAMERGN {
4953    EMR     emr;
4954    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
4955    DWORD   cbRgnData;          // Size of region data in bytes
4956    DWORD   ihBrush;            // Brush handle index
4957    SIZEL   szlStroke;
4958    BYTE[1]    RgnData;
4959}
4960
4961typedef EMRFRAMERGN* PEMRFRAMERGN;
4962typedef EMRFRAMERGN* LPEMRFRAMERGN;
4963
4964struct EMREXTSELECTCLIPRGN {
4965    EMR     emr;
4966    DWORD   cbRgnData;          // Size of region data in bytes
4967    DWORD   iMode;
4968    BYTE[1]    RgnData;
4969}
4970
4971typedef EMREXTSELECTCLIPRGN* PEMREXTSELECTCLIPRGN;
4972typedef EMREXTSELECTCLIPRGN* LPEMREXTSELECTCLIPRGN;
4973
4974struct EMREXTTEXTOUTA {
4975    EMR     emr;
4976    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
4977    DWORD   iGraphicsMode;      // Current graphics mode
4978    FLOAT   exScale;            // X and Y scales from Page units to .01mm units
4979    FLOAT   eyScale;            //   if graphics mode is GM_COMPATIBLE.
4980    EMRTEXT emrtext;            // This is followed by the string and spacing
4981                                // array
4982}
4983
4984typedef EMREXTTEXTOUTA* PEMREXTTEXTOUTA;
4985typedef EMREXTTEXTOUTA* LPEMREXTTEXTOUTA;
4986
4987typedef EMREXTTEXTOUTA EMREXTTEXTOUTW;
4988typedef EMREXTTEXTOUTA* PEMREXTTEXTOUTW;
4989typedef EMREXTTEXTOUTA* LPEMREXTTEXTOUTW;
4990
4991struct EMRPOLYTEXTOUTA {
4992    EMR     emr;
4993    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
4994    DWORD   iGraphicsMode;      // Current graphics mode
4995    FLOAT   exScale;            // X and Y scales from Page units to .01mm units
4996    FLOAT   eyScale;            //   if graphics mode is GM_COMPATIBLE.
4997    LONG    cStrings;
4998    EMRTEXT[1] aemrtext;        // Array of EMRTEXT structures.  This is
4999                                // followed by the strings and spacing arrays.
5000}
5001
5002typedef EMRPOLYTEXTOUTA* PEMRPOLYTEXTOUTA;
5003typedef EMRPOLYTEXTOUTA* LPEMRPOLYTEXTOUTA;
5004
5005typedef EMRPOLYTEXTOUTA EMRPOLYTEXTOUTW;
5006typedef EMRPOLYTEXTOUTA* PEMRPOLYTEXTOUTW;
5007typedef EMRPOLYTEXTOUTA* LPEMRPOLYTEXTOUTW;
5008
5009struct EMRBITBLT {
5010    EMR     emr;
5011    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
5012    LONG    xDest;
5013    LONG    yDest;
5014    LONG    cxDest;
5015    LONG    cyDest;
5016    DWORD   dwRop;
5017    LONG    xSrc;
5018    LONG    ySrc;
5019    XFORM   xformSrc;           // Source DC transform
5020    COLORREF crBkColorSrc;      // Source DC BkColor in RGB
5021    DWORD   iUsageSrc;          // Source bitmap info color table usage
5022                                // (DIB_RGB_COLORS)
5023    DWORD   offBmiSrc;          // Offset to the source BITMAPINFO structure
5024    DWORD   cbBmiSrc;           // Size of the source BITMAPINFO structure
5025    DWORD   offBitsSrc;         // Offset to the source bitmap bits
5026    DWORD   cbBitsSrc;          // Size of the source bitmap bits
5027}
5028
5029typedef EMRBITBLT* PEMRBITBLT;
5030typedef EMRBITBLT* LPEMRBITBLT;
5031
5032struct EMRSTRETCHBLT {
5033    EMR     emr;
5034    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
5035    LONG    xDest;
5036    LONG    yDest;
5037    LONG    cxDest;
5038    LONG    cyDest;
5039    DWORD   dwRop;
5040    LONG    xSrc;
5041    LONG    ySrc;
5042    XFORM   xformSrc;           // Source DC transform
5043    COLORREF crBkColorSrc;      // Source DC BkColor in RGB
5044    DWORD   iUsageSrc;          // Source bitmap info color table usage
5045                                // (DIB_RGB_COLORS)
5046    DWORD   offBmiSrc;          // Offset to the source BITMAPINFO structure
5047    DWORD   cbBmiSrc;           // Size of the source BITMAPINFO structure
5048    DWORD   offBitsSrc;         // Offset to the source bitmap bits
5049    DWORD   cbBitsSrc;          // Size of the source bitmap bits
5050    LONG    cxSrc;
5051    LONG    cySrc;
5052}
5053
5054typedef EMRSTRETCHBLT* PEMRSTRETCHBLT;
5055typedef EMRSTRETCHBLT* LPEMRSTRETCHBLT;
5056
5057struct EMRMASKBLT {
5058    EMR     emr;
5059    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
5060    LONG    xDest;
5061    LONG    yDest;
5062    LONG    cxDest;
5063    LONG    cyDest;
5064    DWORD   dwRop;
5065    LONG    xSrc;
5066    LONG    ySrc;
5067    XFORM   xformSrc;           // Source DC transform
5068    COLORREF crBkColorSrc;      // Source DC BkColor in RGB
5069    DWORD   iUsageSrc;          // Source bitmap info color table usage
5070                                // (DIB_RGB_COLORS)
5071    DWORD   offBmiSrc;          // Offset to the source BITMAPINFO structure
5072    DWORD   cbBmiSrc;           // Size of the source BITMAPINFO structure
5073    DWORD   offBitsSrc;         // Offset to the source bitmap bits
5074    DWORD   cbBitsSrc;          // Size of the source bitmap bits
5075    LONG    xMask;
5076    LONG    yMask;
5077    DWORD   iUsageMask;         // Mask bitmap info color table usage
5078    DWORD   offBmiMask;         // Offset to the mask BITMAPINFO structure if any
5079    DWORD   cbBmiMask;          // Size of the mask BITMAPINFO structure if any
5080    DWORD   offBitsMask;        // Offset to the mask bitmap bits if any
5081    DWORD   cbBitsMask;         // Size of the mask bitmap bits if any
5082}
5083
5084typedef EMRMASKBLT* PEMRMASKBLT;
5085typedef EMRMASKBLT* LPEMRMASKBLT;
5086
5087struct EMRPLGBLT {
5088    EMR     emr;
5089    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
5090    POINTL[3] aptlDest;
5091    LONG    xSrc;
5092    LONG    ySrc;
5093    LONG    cxSrc;
5094    LONG    cySrc;
5095    XFORM   xformSrc;           // Source DC transform
5096    COLORREF crBkColorSrc;      // Source DC BkColor in RGB
5097    DWORD   iUsageSrc;          // Source bitmap info color table usage
5098                                // (DIB_RGB_COLORS)
5099    DWORD   offBmiSrc;          // Offset to the source BITMAPINFO structure
5100    DWORD   cbBmiSrc;           // Size of the source BITMAPINFO structure
5101    DWORD   offBitsSrc;         // Offset to the source bitmap bits
5102    DWORD   cbBitsSrc;          // Size of the source bitmap bits
5103    LONG    xMask;
5104    LONG    yMask;
5105    DWORD   iUsageMask;         // Mask bitmap info color table usage
5106    DWORD   offBmiMask;         // Offset to the mask BITMAPINFO structure if any
5107    DWORD   cbBmiMask;          // Size of the mask BITMAPINFO structure if any
5108    DWORD   offBitsMask;        // Offset to the mask bitmap bits if any
5109    DWORD   cbBitsMask;         // Size of the mask bitmap bits if any
5110}
5111
5112typedef EMRPLGBLT* PEMRPLGBLT;
5113typedef EMRPLGBLT* LPEMRPLGBLT;
5114
5115struct EMRSETDIBITSTODEVICE {
5116    EMR     emr;
5117    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
5118    LONG    xDest;
5119    LONG    yDest;
5120    LONG    xSrc;
5121    LONG    ySrc;
5122    LONG    cxSrc;
5123    LONG    cySrc;
5124    DWORD   offBmiSrc;          // Offset to the source BITMAPINFO structure
5125    DWORD   cbBmiSrc;           // Size of the source BITMAPINFO structure
5126    DWORD   offBitsSrc;         // Offset to the source bitmap bits
5127    DWORD   cbBitsSrc;          // Size of the source bitmap bits
5128    DWORD   iUsageSrc;          // Source bitmap info color table usage
5129    DWORD   iStartScan;
5130    DWORD   cScans;
5131}
5132
5133typedef EMRSETDIBITSTODEVICE* PEMRSETDIBITSTODEVICE;
5134typedef EMRSETDIBITSTODEVICE* LPEMRSETDIBITSTODEVICE;
5135
5136struct EMRSTRETCHDIBITS {
5137    EMR     emr;
5138    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
5139    LONG    xDest;
5140    LONG    yDest;
5141    LONG    xSrc;
5142    LONG    ySrc;
5143    LONG    cxSrc;
5144    LONG    cySrc;
5145    DWORD   offBmiSrc;          // Offset to the source BITMAPINFO structure
5146    DWORD   cbBmiSrc;           // Size of the source BITMAPINFO structure
5147    DWORD   offBitsSrc;         // Offset to the source bitmap bits
5148    DWORD   cbBitsSrc;          // Size of the source bitmap bits
5149    DWORD   iUsageSrc;          // Source bitmap info color table usage
5150    DWORD   dwRop;
5151    LONG    cxDest;
5152    LONG    cyDest;
5153}
5154
5155typedef EMRSTRETCHDIBITS* PEMRSTRETCHDIBITS;
5156typedef EMRSTRETCHDIBITS* LPEMRSTRETCHDIBITS;
5157
5158struct EMREXTCREATEFONTINDIRECTW {
5159    EMR     emr;
5160    DWORD   ihFont;             // Font handle index
5161    EXTLOGFONTW elfw;
5162} 
5163
5164typedef EMREXTCREATEFONTINDIRECTW* PEMREXTCREATEFONTINDIRECTW;
5165typedef EMREXTCREATEFONTINDIRECTW* LPEMREXTCREATEFONTINDIRECTW;
5166
5167struct EMRCREATEPALETTE {
5168    EMR     emr;
5169    DWORD   ihPal;              // Palette handle index
5170    LOGPALETTE lgpl;            // The peFlags fields in the palette entries
5171                                // do not contain any flags
5172}
5173
5174typedef EMRCREATEPALETTE* PEMRCREATEPALETTE;
5175typedef EMRCREATEPALETTE* LPEMRCREATEPALETTE;
5176
5177struct EMRCREATEPEN {
5178    EMR     emr;
5179    DWORD   ihPen;              // Pen handle index
5180    LOGPEN  lopn;
5181}
5182
5183typedef EMRCREATEPEN* PEMRCREATEPEN;
5184typedef EMRCREATEPEN* LPEMRCREATEPEN;
5185
5186struct EMREXTCREATEPEN {
5187    EMR     emr;
5188    DWORD   ihPen;              // Pen handle index
5189    DWORD   offBmi;             // Offset to the BITMAPINFO structure if any
5190    DWORD   cbBmi;              // Size of the BITMAPINFO structure if any
5191                                // The bitmap info is followed by the bitmap
5192                                // bits to form a packed DIB.
5193    DWORD   offBits;            // Offset to the brush bitmap bits if any
5194    DWORD   cbBits;             // Size of the brush bitmap bits if any
5195    EXTLOGPEN elp;              // The extended pen with the style array.
5196}
5197
5198typedef EMREXTCREATEPEN* PEMREXTCREATEPEN;
5199typedef EMREXTCREATEPEN* LPEMREXTCREATEPEN;
5200
5201struct EMRCREATEBRUSHINDIRECT {
5202    EMR        emr;
5203    DWORD      ihBrush;          // Brush handle index
5204    LOGBRUSH32 lb;               // The style must be BS_SOLID, BS_HOLLOW,
5205                                 // BS_NULL or BS_HATCHED.
5206}
5207
5208typedef EMRCREATEBRUSHINDIRECT* PEMRCREATEBRUSHINDIRECT;
5209typedef EMRCREATEBRUSHINDIRECT* LPEMRCREATEBRUSHINDIRECT;
5210
5211struct EMRCREATEMONOBRUSH {
5212    EMR     emr;
5213    DWORD   ihBrush;            // Brush handle index
5214    DWORD   iUsage;             // Bitmap info color table usage
5215    DWORD   offBmi;             // Offset to the BITMAPINFO structure
5216    DWORD   cbBmi;              // Size of the BITMAPINFO structure
5217    DWORD   offBits;            // Offset to the bitmap bits
5218    DWORD   cbBits;             // Size of the bitmap bits
5219}
5220
5221typedef EMRCREATEMONOBRUSH* PEMRCREATEMONOBRUSH;
5222typedef EMRCREATEMONOBRUSH* LPEMRCREATEMONOBRUSH;
5223
5224struct EMRCREATEDIBPATTERNBRUSHPT {
5225    EMR     emr;
5226    DWORD   ihBrush;            // Brush handle index
5227    DWORD   iUsage;             // Bitmap info color table usage
5228    DWORD   offBmi;             // Offset to the BITMAPINFO structure
5229    DWORD   cbBmi;              // Size of the BITMAPINFO structure
5230                                // The bitmap info is followed by the bitmap
5231                                // bits to form a packed DIB.
5232    DWORD   offBits;            // Offset to the bitmap bits
5233    DWORD   cbBits;             // Size of the bitmap bits
5234}
5235
5236typedef EMRCREATEDIBPATTERNBRUSHPT* PEMRCREATEDIBPATTERNBRUSHPT;
5237typedef EMRCREATEDIBPATTERNBRUSHPT* LPEMRCREATEDIBPATTERNBRUSHPT;
5238
5239struct EMRFORMAT {
5240    DWORD   dSignature;         // Format signature, e.g. ENHMETA_SIGNATURE.
5241    DWORD   nVersion;           // Format version number.
5242    DWORD   cbData;             // Size of data in bytes.
5243    DWORD   offData;            // Offset to data from GDICOMMENT_IDENTIFIER.
5244                                // It must begin at a DWORD offset.
5245}
5246
5247typedef EMRFORMAT* PEMRFORMAT;
5248typedef EMRFORMAT* LPEMRFORMAT;
5249
5250struct EMRGLSRECORD {
5251    EMR     emr;
5252    DWORD   cbData;             // Size of data in bytes
5253    BYTE[1]    Data;
5254}
5255
5256typedef EMRGLSRECORD* PEMRGLSRECORD;
5257typedef EMRGLSRECORD* LPEMRGLSRECORD;
5258
5259struct EMRGLSBOUNDEDRECORD {
5260    EMR     emr;
5261    RECTL   rclBounds;          // Bounds in recording coordinates
5262    DWORD   cbData;             // Size of data in bytes
5263    BYTE[1]    Data;
5264}
5265
5266typedef EMRGLSBOUNDEDRECORD* PEMRGLSBOUNDEDRECORD;
5267typedef EMRGLSBOUNDEDRECORD* LPEMRGLSBOUNDEDRECORD;
5268
5269struct EMRPIXELFORMAT {
5270    EMR     emr;
5271    PIXELFORMATDESCRIPTOR pfd;
5272}
5273
5274typedef EMRPIXELFORMAT* PEMRPIXELFORMAT;
5275typedef EMRPIXELFORMAT* LPEMRPIXELFORMAT;
5276
5277struct EMRCREATECOLORSPACE {
5278    EMR             emr;
5279    DWORD           ihCS;       // ColorSpace handle index
5280    LOGCOLORSPACEA  lcs;        // Ansi version of LOGCOLORSPACE
5281}
5282
5283typedef EMRCREATECOLORSPACE* PEMRCREATECOLORSPACE;
5284typedef EMRCREATECOLORSPACE* LPEMRCREATECOLORSPACE;
5285
5286struct EMRSETCOLORSPACE {
5287    EMR     emr;
5288    DWORD   ihCS;               // ColorSpace handle index
5289}
5290
5291typedef EMRSETCOLORSPACE* PEMRSETCOLORSPACE;
5292typedef EMRSETCOLORSPACE* LPEMRSETCOLORSPACE;
5293
5294typedef EMRSETCOLORSPACE EMRSELECTCOLORSPACE;
5295typedef EMRSETCOLORSPACE* PEMRSELECTCOLORSPACE;
5296typedef EMRSETCOLORSPACE* LPEMRSELECTCOLORSPACE;
5297
5298typedef EMRSETCOLORSPACE EMRDELETECOLORSPACE;
5299typedef EMRSETCOLORSPACE* PEMRDELETECOLORSPACE;
5300typedef EMRSETCOLORSPACE* LPEMRDELETECOLORSPACE;
5301
5302struct EMREXTESCAPE {
5303    EMR     emr;
5304    INT     iEscape;            // Escape code
5305    INT     cbEscData;          // Size of escape data
5306    BYTE[1]    EscData;         // Escape data
5307}
5308
5309typedef EMREXTESCAPE* PEMREXTESCAPE;
5310typedef EMREXTESCAPE* LPEMREXTESCAPE;
5311
5312typedef EMREXTESCAPE EMRDRAWESCAPE;
5313typedef EMREXTESCAPE* PEMRDRAWESCAPE;
5314typedef EMREXTESCAPE* LPEMRDRAWESCAPE;
5315
5316struct EMRNAMEDESCAPE {
5317    EMR     emr;
5318    INT     iEscape;            // Escape code
5319    INT     cbDriver;           // Size of driver name
5320    INT     cbEscData;          // Size of escape data
5321    BYTE[1]    EscData;         // Driver name and Escape data
5322}
5323
5324typedef EMRNAMEDESCAPE* PEMRNAMEDESCAPE;
5325typedef EMRNAMEDESCAPE* LPEMRNAMEDESCAPE;
5326
5327const auto SETICMPROFILE_EMBEDED           = 0x00000001;
5328
5329struct EMRSETICMPROFILE {
5330    EMR     emr;
5331    DWORD   dwFlags;            // flags
5332    DWORD   cbName;             // Size of desired profile name
5333    DWORD   cbData;             // Size of raw profile data if attached
5334    BYTE[1]    Data;            // Array size is cbName + cbData
5335}
5336
5337typedef EMRSETICMPROFILE* PEMRSETICMPROFILE;
5338typedef EMRSETICMPROFILE* LPEMRSETICMPROFILE;
5339
5340typedef EMRSETICMPROFILE EMRSETICMPROFILEA;
5341typedef EMRSETICMPROFILE* PEMRSETICMPROFILEA;
5342typedef EMRSETICMPROFILE* LPEMRSETICMPROFILEA;
5343
5344typedef EMRSETICMPROFILE EMRSETICMPROFILEW;
5345typedef EMRSETICMPROFILE* PEMRSETICMPROFILEW;
5346typedef EMRSETICMPROFILE* LPEMRSETICMPROFILEW;
5347
5348const auto CREATECOLORSPACE_EMBEDED        = 0x00000001;
5349
5350struct EMRCREATECOLORSPACEW {
5351    EMR             emr;
5352    DWORD           ihCS;       // ColorSpace handle index
5353    LOGCOLORSPACEW  lcs;        // Unicode version of logical color space structure
5354    DWORD           dwFlags;    // flags
5355    DWORD           cbData;     // size of raw source profile data if attached
5356    BYTE[1]            Data;    // Array size is cbData
5357}
5358
5359typedef EMRCREATECOLORSPACEW* PEMRCREATECOLORSPACEW;
5360typedef EMRCREATECOLORSPACEW* LPEMRCREATECOLORSPACEW;
5361
5362const auto COLORMATCHTOTARGET_EMBEDED      = 0x00000001;
5363
5364struct EMRCOLORMATCHTOTARGET {
5365    EMR     emr;
5366    DWORD   dwAction;           // CS_ENABLE, CS_DISABLE or CS_DELETE_TRANSFORM
5367    DWORD   dwFlags;            // flags
5368    DWORD   cbName;             // Size of desired target profile name
5369    DWORD   cbData;             // Size of raw target profile data if attached
5370    BYTE[1]    Data;            // Array size is cbName + cbData
5371}
5372
5373typedef EMRCOLORMATCHTOTARGET* PEMRCOLORMATCHTOTARGET;
5374typedef EMRCOLORMATCHTOTARGET* LPEMRCOLORMATCHTOTARGET;
5375
5376struct EMRCOLORCORRECTPALETTE {
5377    EMR     emr;
5378    DWORD   ihPalette;          // Palette handle index
5379    DWORD   nFirstEntry;        // Index of first entry to correct
5380    DWORD   nPalEntries;        // Number of palette entries to correct
5381    DWORD   nReserved;          // Reserved
5382}
5383
5384typedef EMRCOLORCORRECTPALETTE* PEMRCOLORCORRECTPALETTE;
5385typedef EMRCOLORCORRECTPALETTE* LPEMRCOLORCORRECTPALETTE;
5386
5387struct EMRALPHABLEND {
5388    EMR     emr;
5389    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
5390    LONG    xDest;
5391    LONG    yDest;
5392    LONG    cxDest;
5393    LONG    cyDest;
5394    DWORD   dwRop;
5395    LONG    xSrc;
5396    LONG    ySrc;
5397    XFORM   xformSrc;           // Source DC transform
5398    COLORREF crBkColorSrc;      // Source DC BkColor in RGB
5399    DWORD   iUsageSrc;          // Source bitmap info color table usage
5400                                // (DIB_RGB_COLORS)
5401    DWORD   offBmiSrc;          // Offset to the source BITMAPINFO structure
5402    DWORD   cbBmiSrc;           // Size of the source BITMAPINFO structure
5403    DWORD   offBitsSrc;         // Offset to the source bitmap bits
5404    DWORD   cbBitsSrc;          // Size of the source bitmap bits
5405    LONG    cxSrc;
5406    LONG    cySrc;
5407}
5408
5409typedef EMRALPHABLEND* PEMRALPHABLEND;
5410typedef EMRALPHABLEND* LPEMRALPHABLEND;
5411
5412struct EMRGRADIENTFILL {
5413    EMR       emr;
5414    RECTL     rclBounds;          // Inclusive-inclusive bounds in device units
5415    DWORD     nVer;
5416    DWORD     nTri;
5417    ULONG     ulMode;
5418    TRIVERTEX[1] Ver;
5419}
5420
5421typedef EMRGRADIENTFILL* PEMRGRADIENTFILL;
5422typedef EMRGRADIENTFILL* LPEMRGRADIENTFILL;
5423
5424struct EMRTRANSPARENTBLT {
5425    EMR     emr;
5426    RECTL   rclBounds;          // Inclusive-inclusive bounds in device units
5427    LONG    xDest;
5428    LONG    yDest;
5429    LONG    cxDest;
5430    LONG    cyDest;
5431    DWORD   dwRop;
5432    LONG    xSrc;
5433    LONG    ySrc;
5434    XFORM   xformSrc;           // Source DC transform
5435    COLORREF crBkColorSrc;      // Source DC BkColor in RGB
5436    DWORD   iUsageSrc;          // Source bitmap info color table usage
5437                                // (DIB_RGB_COLORS)
5438    DWORD   offBmiSrc;          // Offset to the source BITMAPINFO structure
5439    DWORD   cbBmiSrc;           // Size of the source BITMAPINFO structure
5440    DWORD   offBitsSrc;         // Offset to the source bitmap bits
5441    DWORD   cbBitsSrc;          // Size of the source bitmap bits
5442    LONG    cxSrc;
5443    LONG    cySrc;
5444}
5445
5446typedef EMRTRANSPARENTBLT* PEMRTRANSPARENTBLT;
5447typedef EMRTRANSPARENTBLT* LPEMRTRANSPARENTBLT;
5448
5449const auto GDICOMMENT_IDENTIFIER           = 0x43494447;
5450const auto GDICOMMENT_WINDOWS_METAFILE     = 0x80000001;
5451const auto GDICOMMENT_BEGINGROUP           = 0x00000002;
5452const auto GDICOMMENT_ENDGROUP             = 0x00000003;
5453const auto GDICOMMENT_MULTIFORMATS         = 0x40000004;
5454const auto EPS_SIGNATURE                   = 0x46535045;
5455const auto GDICOMMENT_UNICODE_STRING       = 0x00000040;
5456const auto GDICOMMENT_UNICODE_END          = 0x00000080;
5457
5458// OpenGL wgl prototypes
5459
5460BOOL  wglCopyContext(HGLRC, HGLRC, UINT);
5461HGLRC wglCreateContext(HDC);
5462HGLRC wglCreateLayerContext(HDC, int);
5463BOOL  wglDeleteContext(HGLRC);
5464HGLRC wglGetCurrentContext();
5465HDC   wglGetCurrentDC();
5466PROC  wglGetProcAddress(LPCSTR);
5467BOOL  wglMakeCurrent(HDC, HGLRC);
5468BOOL  wglShareLists(HGLRC, HGLRC);
5469BOOL  wglUseFontBitmapsA(HDC, DWORD, DWORD, DWORD);
5470BOOL  wglUseFontBitmapsW(HDC, DWORD, DWORD, DWORD);
5471
5472version(UNICODE) {
5473	alias wglUseFontBitmapsW  wglUseFontBitmaps;
5474}
5475else {
5476	alias wglUseFontBitmapsA  wglUseFontBitmaps;
5477}
5478
5479BOOL  SwapBuffers(HDC);
5480
5481struct POINTFLOAT {
5482    FLOAT   x;
5483    FLOAT   y;
5484}
5485
5486typedef POINTFLOAT* PPOINTFLOAT;
5487typedef POINTFLOAT* LPPOINTFLOAT;
5488
5489struct GLYPHMETRICSFLOAT {
5490    FLOAT       gmfBlackBoxX;
5491    FLOAT       gmfBlackBoxY;
5492    POINTFLOAT  gmfptGlyphOrigin;
5493    FLOAT       gmfCellIncX;
5494    FLOAT       gmfCellIncY;
5495}
5496
5497typedef GLYPHMETRICSFLOAT* PGLYPHMETRICSFLOAT;
5498typedef GLYPHMETRICSFLOAT* LPGLYPHMETRICSFLOAT;
5499
5500const auto WGL_FONT_LINES      = 0;
5501const auto WGL_FONT_POLYGONS   = 1;
5502BOOL  wglUseFontOutlinesA(HDC, DWORD, DWORD, DWORD, FLOAT,
5503                                           FLOAT, int, LPGLYPHMETRICSFLOAT);
5504BOOL  wglUseFontOutlinesW(HDC, DWORD, DWORD, DWORD, FLOAT,
5505                                           FLOAT, int, LPGLYPHMETRICSFLOAT);
5506
5507version(UNICODE) {
5508	alias wglUseFontOutlinesW  wglUseFontOutlines;
5509}
5510else {
5511	alias wglUseFontOutlinesA  wglUseFontOutlines;
5512}
5513
5514/* Layer plane descriptor */
5515struct LAYERPLANEDESCRIPTOR { // lpd
5516    WORD  nSize;
5517    WORD  nVersion;
5518    DWORD dwFlags;
5519    BYTE  iPixelType;
5520    BYTE  cColorBits;
5521    BYTE  cRedBits;
5522    BYTE  cRedShift;
5523    BYTE  cGreenBits;
5524    BYTE  cGreenShift;
5525    BYTE  cBlueBits;
5526    BYTE  cBlueShift;
5527    BYTE  cAlphaBits;
5528    BYTE  cAlphaShift;
5529    BYTE  cAccumBits;
5530    BYTE  cAccumRedBits;
5531    BYTE  cAccumGreenBits;
5532    BYTE  cAccumBlueBits;
5533    BYTE  cAccumAlphaBits;
5534    BYTE  cDepthBits;
5535    BYTE  cStencilBits;
5536    BYTE  cAuxBuffers;
5537    BYTE  iLayerPlane;
5538    BYTE  bReserved;
5539    COLORREF crTransparent;
5540}
5541
5542typedef LAYERPLANEDESCRIPTOR* PLAYERPLANEDESCRIPTOR;
5543typedef LAYERPLANEDESCRIPTOR* LPLAYERPLANEDESCRIPTOR;
5544
5545/* LAYERPLANEDESCRIPTOR flags */
5546const auto LPD_DOUBLEBUFFER        = 0x00000001;
5547const auto LPD_STEREO              = 0x00000002;
5548const auto LPD_SUPPORT_GDI         = 0x00000010;
5549const auto LPD_SUPPORT_OPENGL      = 0x00000020;
5550const auto LPD_SHARE_DEPTH         = 0x00000040;
5551const auto LPD_SHARE_STENCIL       = 0x00000080;
5552const auto LPD_SHARE_ACCUM         = 0x00000100;
5553const auto LPD_SWAP_EXCHANGE       = 0x00000200;
5554const auto LPD_SWAP_COPY           = 0x00000400;
5555const auto LPD_TRANSPARENT         = 0x00001000;
5556
5557const auto LPD_TYPE_RGBA        = 0;
5558const auto LPD_TYPE_COLORINDEX  = 1;
5559
5560/* wglSwapLayerBuffers flags */
5561const auto WGL_SWAP_MAIN_PLANE     = 0x00000001;
5562const auto WGL_SWAP_OVERLAY1       = 0x00000002;
5563const auto WGL_SWAP_OVERLAY2       = 0x00000004;
5564const auto WGL_SWAP_OVERLAY3       = 0x00000008;
5565const auto WGL_SWAP_OVERLAY4       = 0x00000010;
5566const auto WGL_SWAP_OVERLAY5       = 0x00000020;
5567const auto WGL_SWAP_OVERLAY6       = 0x00000040;
5568const auto WGL_SWAP_OVERLAY7       = 0x00000080;
5569const auto WGL_SWAP_OVERLAY8       = 0x00000100;
5570const auto WGL_SWAP_OVERLAY9       = 0x00000200;
5571const auto WGL_SWAP_OVERLAY10      = 0x00000400;
5572const auto WGL_SWAP_OVERLAY11      = 0x00000800;
5573const auto WGL_SWAP_OVERLAY12      = 0x00001000;
5574const auto WGL_SWAP_OVERLAY13      = 0x00002000;
5575const auto WGL_SWAP_OVERLAY14      = 0x00004000;
5576const auto WGL_SWAP_OVERLAY15      = 0x00008000;
5577const auto WGL_SWAP_UNDERLAY1      = 0x00010000;
5578const auto WGL_SWAP_UNDERLAY2      = 0x00020000;
5579const auto WGL_SWAP_UNDERLAY3      = 0x00040000;
5580const auto WGL_SWAP_UNDERLAY4      = 0x00080000;
5581const auto WGL_SWAP_UNDERLAY5      = 0x00100000;
5582const auto WGL_SWAP_UNDERLAY6      = 0x00200000;
5583const auto WGL_SWAP_UNDERLAY7      = 0x00400000;
5584const auto WGL_SWAP_UNDERLAY8      = 0x00800000;
5585const auto WGL_SWAP_UNDERLAY9      = 0x01000000;
5586const auto WGL_SWAP_UNDERLAY10     = 0x02000000;
5587const auto WGL_SWAP_UNDERLAY11     = 0x04000000;
5588const auto WGL_SWAP_UNDERLAY12     = 0x08000000;
5589const auto WGL_SWAP_UNDERLAY13     = 0x10000000;
5590const auto WGL_SWAP_UNDERLAY14     = 0x20000000;
5591const auto WGL_SWAP_UNDERLAY15     = 0x40000000;
5592
5593BOOL  wglDescribeLayerPlane(HDC, int, int, UINT,
5594                                             LPLAYERPLANEDESCRIPTOR);
5595int   wglSetLayerPaletteEntries(HDC, int, int, int,
5596                                                 COLORREF *);
5597int   wglGetLayerPaletteEntries(HDC, int, int, int,
5598                                                 COLORREF *);
5599BOOL  wglRealizeLayerPalette(HDC, int, BOOL);
5600BOOL  wglSwapLayerBuffers(HDC, UINT);
5601
5602struct WGLSWAP {
5603    HDC hdc;
5604    UINT uiFlags;
5605}
5606
5607typedef WGLSWAP* PWGLSWAP;
5608typedef WGLSWAP* LPWGLSWAP;
5609
5610const auto WGL_SWAPMULTIPLE_MAX = 16;
5611
5612DWORD wglSwapMultipleBuffers(UINT, WGLSWAP *);