' api_gdi.sbp - Graphics Device Integerface API


#ifndef _INC_GDI
#define _INC_GDI

#ifdef UNICODE
Const _FuncName_CopyEnhMetaFile = "CopyEnhMetaFileW"
Const _FuncName_CopyMetaFile = "CopyMetaFileW"
Const _FuncName_CreateDC = "CreateDCW"
Const _FuncName_CreateEnhMetaFile = "CreateEnhMetaFileW"
Const _FuncName_CreateMetaFile = "CreateMetaFileW"
Const _FuncName_CreateFont = "CreateFontW"
Const _FuncName_CreateFontIndirect = "CreateFontIndirectW"
Const _FuncName_GetEnhMetaFile = "GetEnhMetaFileW"
Const _FuncName_GetEnhMetaFileDescription = "GetEnhMetaFileDescriptionW"
Const _FuncName_GetObject = "GetObjectW"
Const _FuncName_GetTextFace = "GetTextFaceW"
Const _FuncName_GetTextMetrics = "GetTextMetricsW"
Const _FuncName_ResetDC = "ResetDCW"
Const _FuncName_StartDoc = "StartDocW"
Const _FuncName_wglUseFontBitmaps = "wglUseFontBitmapsW"
Const _FuncName_wglUseFontOutlines = "wglUseFontOutlinesW"
#else
Const _FuncName_CopyEnhMetaFile = "CopyEnhMetaFileA"
Const _FuncName_CopyMetaFile = "CopyMetaFileA"
Const _FuncName_CreateDC = "CreateDCA"
Const _FuncName_CreateEnhMetaFile = "CreateEnhMetaFileA"
Const _FuncName_CreateMetaFile = "CreateMetaFileA"
Const _FuncName_CreateFont = "CreateFontA"
Const _FuncName_CreateFontIndirect = "CreateFontIndirectA"
Const _FuncName_GetEnhMetaFile = "GetEnhMetaFileA"
Const _FuncName_GetEnhMetaFileDescription = "GetEnhMetaFileDescriptionA"
Const _FuncName_GetObject = "GetObjectA"
Const _FuncName_GetTextFace = "GetTextFaceA"
Const _FuncName_GetTextMetrics = "GetTextMetricsA"
Const _FuncName_ResetDC = "ResetDCA"
Const _FuncName_StartDoc = "StartDocA"
Const _FuncName_wglUseFontBitmaps = "wglUseFontBitmapsA"
Const _FuncName_wglUseFontOutlines = "wglUseFontOutlinesA"
#endif

Const CLR_INVALID =   &HFFFFFFFF
Const GDI_ERROR =     &HFFFFFFFF

TypeDef BCHAR = TBYTE

' Metafile and EnhancedMetafile
Type EMR
	iType As DWord
	nSize As DWord
End Type

Type Align(2) METAHEADER
	mtType As Word
	mtHeaderSize As Word
	mtVersion As Word
	mtSize As DWord
	mtNoObjects As Word
	mtMaxRecord As DWord
	mtNoParameters As Word
End Type
TypeDef PMETAHEADER = *METAHEADER

Type ENHMETAHEADER
    iType As DWord
    nSize As DWord
    rclBounds As RECT
    rclFrame As RECT
    dSignature As DWord
    nVersion As DWord
    nBytes As DWord
    nRecords As DWord
    nHandles As Word
    sReserved As Word
    nDescription As DWord
    offDescription As DWord
    nPalEntries As DWord
    szlDevice As SIZE
    szlMillimeters As SIZE
    cbPixelFormat As DWord
    offPixelFormat As DWord
    bOpenGL As DWord
'#if WINVER >= 0x0500
    'szlMicrometers As SIZE
'#endif
End Type
TypeDef PENHMETAHEADER = *ENHMETAHEADER

Type HANDLETABLE
	objectHandle[ELM(1)] As HGDIOBJ
End Type

Type METARECORD
	rdSize As DWord
	rdFunction As Word
	rdParm[ELM(1)] As Word
End Type

Type ENHMETARECORD
	iType As DWord
	nSize As DWord
	dParm[ELM(1)] As DWord
End Type

Type METAFILEPICT
	mm As Long
	xExt As Long
	yExt As Long
	hMF As HMETAFILE
End Type

TypeDef ENHMFENUMPROC = *Function(hdc As HDC, ByRef HTable As HANDLETABLE, ByRef EMFR As ENHMETARECORD, nObj As Long, lpData As LPARAM) As Long
TypeDef MFENUMPROC = *Function(hdc As HDC, ByRef HTable As HANDLETABLE, ByRef MFR As METARECORD, nObj As Long, lpClientData As LPARAM) As Long


' RGB Color
Const RGB(r, g, b) = ((r) As Long) Or (((g) As Long) <<8) Or (((b) As Long) <<16)
Const PALETTERGB(r, g, b) = (&h02000000 Or RGB(r,g,b))
Const PALETTEINDEX(i) = ((&h01000000 Or (i) As Word As DWord) As COLORREF)

Const GetRValue(rgb) = (rgb And &hff)
Const GetGValue(rgb) = ((rgb >> 8) And &hff)
Const GetBValue(rgb) = ((rgb >> 16) And &hff)

Type RGBQUAD
	rgbBlue As Byte
	rgbGreen As Byte
	rgbRed As Byte
	rgbReserved As Byte
End Type

Type Align(1) RGBTRIPLE
	rgbtBlue As Byte
	rgbtGreen As Byte
	rgbtRed As Byte
End Type

' CMYK Color
Const GetKValue(cmyk) = ((cmyk) As Byte)
Const GetYValue(cmyk) = (((cmyk) >> 8) As Byte)
Const GetMValue(cmyk) = (((cmyk) >> 16) As Byte)
Const GetCValue(cmyk) = (((cmyk) >> 24) As Byte)

Const CMYK(c, m, y, k) = (( _
	((k) As Byte) Or _
	((y) As Byte As Word << 8) Or _
	((m) As Byte As DWord << 16) Or _
	((c) As Byte As DWord << 24)) As COLORREF)

' ICM Color
TypeDef FXPT16DOT16 = Long
TypeDef FXPT2DOT30 = Long

TypeDef LCSCSTYPE = Long
TypeDef LCSGAMUTMATCH = Long

Type LOGCOLORSPACEA
	lcsSignature As DWord
	lcsVersion As DWord
	lcsSize As DWord
	lcsCSType As LCSCSTYPE
	lcsIntent As LCSGAMUTMATCH
	lcsEndpoints As CIEXYZTRIPLE
	lcsGammaRed As DWord
	lcsGammaGreen As DWord
	lcsGammaBlue As DWord
	lcsFilename[MAX_PATH] As SByte
End Type
Type LOGCOLORSPACEW
	lcsSignature As DWord
	lcsVersion As DWord
	lcsSize As DWord
	lcsCSType As LCSCSTYPE
	lcsIntent As LCSGAMUTMATCH
	lcsEndpoints As CIEXYZTRIPLE
	lcsGammaRed As DWord
	lcsGammaGreen As DWord
	lcsGammaBlue As DWord
	lcsFilename[ELM(MAX_PATH)] As WCHAR
End Type
#ifdef UNICODE
TypeDef LOGCOLORSPACE = LOGCOLORSPACEW
#else
TypeDef LOGCOLORSPACE = LOGCOLORSPACEA
#endif

Type CIEXYZ
	ciexyzX As FXPT2DOT30
	ciexyzY As FXPT2DOT30
	ciexyzZ As FXPT2DOT30
End Type

Type CIEXYZTRIPLE
	ciexyzRed As CIEXYZ
	ciexyzGreen As CIEXYZ
	ciexyzBlue As CIEXYZ
End Type

Type LOGPALETTE
	palVersion As Word
	palNumEntries As Word
	palPalEntry[ELM(1)] As PALETTEENTRY
End Type

' raster operations
Const SRCCOPY =           &H00CC0020
Const SRCPAINT =          &H00EE0086
Const SRCAND =            &H008800C6
Const SRCINVERT =         &H00660046
Const SRCERASE =          &H00440328
Const NOTSRCCOPY =        &H00330008
Const NOTSRCERASE =       &H001100A6
Const MERGECOPY =         &H00C000CA
Const MERGEPAINT =        &H00BB0226
Const PATCOPY =           &H00F00021
Const PATPAINT =          &H00FB0A09
Const PATINVERT =         &H005A0049
Const DSTINVERT =         &H00550009
Const BLACKNESS =         &H00000042
Const WHITENESS =         &H00FF0062


' Object types
Const OBJ_PEN =           1
Const OBJ_BRUSH =         2
Const OBJ_DC =            3
Const OBJ_METADC =        4
Const OBJ_PAL =           5
Const OBJ_FONT =          6
Const OBJ_BITMAP =        7
Const OBJ_REGION =        8
Const OBJ_METAFILE =      9
Const OBJ_MEMDC =         10
Const OBJ_EXTPEN =        11
Const OBJ_ENHMETADC =     12
Const OBJ_ENHMETAFILE =   13


' Bitmap Header Definition
Type BITMAP
	bmType As Long
	bmWidth As Long
	bmHeight As Long
	bmWidthBytes As Long
	bmPlanes As Word
	bmBitsPixel As Word
	bmBits As VoidPtr
End Type

Type BITMAPCOREHEADER
	bcSize As DWord
	bcWidth As Word
	bcHeight As Word
	bcPlanes As Word
	bcBitCount As Word
End Type

Type BITMAPCOREINFO
	bmciHeader As BITMAPCOREHEADER
	bmciColors[ELM(1)] As RGBTRIPLE
End Type

' structures for defining DIBs
Const BI_RGB =       0
Const BI_RLE8 =      1
Const BI_RLE4 =      2
Const BI_BITFIELDS = 3
Const BI_JPEG =      4
Const BI_PNG =       5

Type BITMAPINFOHEADER
	biSize As DWord
	biWidth As Long
	biHeight As Long
	biPlanes As Word
	biBitCount As Word
	biCompression As DWord
	biSizeImage As DWord
	biXPelsPerMeter As Long
	biYPelsPerMeter As Long
	biClrUsed As DWord
	biClrImportant As DWord
End Type

Type BITMAPINFO
	bmiHeader As BITMAPINFOHEADER
	bmiColors[ELM(1)] As RGBQUAD '以前はbmpColors[255] As RGBQUADだったことに注意
End Type


' Bitmap file header struct
Type Align(2) BITMAPFILEHEADER
	bfType As Word
	bfSize As DWord
	bfReserved1 As Word
	bfReserved2 As Word
	bfOffBits As DWord
End Type

Type BITMAPV4HEADER
	bV4Size As DWord
	bV4Width As Long
	bV4Height As Long
	bV4Planes As Word
	bV4BitCount As Word
	bV4V4Compression As DWord
	bV4SizeImage As DWord
	bV4XPelsPerMeter As Long
	bV4YPelsPerMeter As Long
	bV4ClrUsed As DWord
	bV4ClrImportant As DWord
	bV4RedMask As DWord
	bV4GreenMask As DWord
	bV4BlueMask As DWord
	bV4AlphaMask As DWord
	bV4CSType As DWord
	bV4Endpoints As CIEXYZTRIPLE
	bV4GammaRed As DWord
	bV4GammaGreen As DWord
	bV4GammaBlue As DWord
End Type

' Region flags
Const NULLREGION =    1
Const SIMPLEREGION =  2
Const COMPLEXREGION = 3


' Poly fill mode
Const ALTERNATE = 1
Const WINDING   = 2


' Device mode
Const DM_ORIENTATION =      &H00000001
Const DM_PAPERSIZE =        &H00000002
Const DM_PAPERLENGTH =      &H00000004
Const DM_PAPERWIDTH =       &H00000008
Const DM_SCALE =            &H00000010
Const DM_POSITION =         &H00000020
Const DM_COPIES =           &H00000100
Const DM_DEFAULTSOURCE =    &H00000200
Const DM_PRINTQUALITY =     &H00000400
Const DM_COLOR =            &H00000800
Const DM_DUPLEX =           &H00001000
Const DM_YRESOLUTION =      &H00002000
Const DM_TTOPTION =         &H00004000
Const DM_COLLATE =          &H00008000
Const DM_FORMNAME =         &H00010000
Const DM_LOGPIXELS =        &H00020000
Const DM_BITSPERPEL =       &H00040000
Const DM_PELSWIDTH =        &H00080000
Const DM_PELSHEIGHT =       &H00100000
Const DM_DISPLAYFLAGS =     &H00200000
Const DM_DISPLAYFREQUENCY = &H00400000
Const DMORIENT_PORTRAIT =   1
Const DMORIENT_LANDSCAPE =  2
Const DMPAPER_LETTER =              1
Const DMPAPER_LETTERSMALL =         2
Const DMPAPER_TABLOID =             3
Const DMPAPER_LEDGER =              4
Const DMPAPER_LEGAL =               5
Const DMPAPER_STATEMENT =           6
Const DMPAPER_EXECUTIVE =           7
Const DMPAPER_A3 =                  8
Const DMPAPER_A4 =                  9
Const DMPAPER_A4SMALL =            10
Const DMPAPER_A5 =                 11
Const DMPAPER_B4 =                 12
Const DMPAPER_B5 =                 13
Const DMPAPER_FOLIO =              14
Const DMPAPER_QUARTO =             15
Const DMPAPER_10X14 =              16
Const DMPAPER_11X17 =              17
Const DMPAPER_NOTE =               18
Const DMPAPER_ENV_9 =              19
Const DMPAPER_ENV_10 =             20
Const DMPAPER_ENV_11 =             21
Const DMPAPER_ENV_12 =             22
Const DMPAPER_ENV_14 =             23
Const DMPAPER_CSHEET =             24
Const DMPAPER_DSHEET =             25
Const DMPAPER_ESHEET =             26
Const DMPAPER_ENV_DL =             27
Const DMPAPER_ENV_C5 =             28
Const DMPAPER_ENV_C3 =             29
Const DMPAPER_ENV_C4 =             30
Const DMPAPER_ENV_C6 =             31
Const DMPAPER_ENV_C65 =            32
Const DMPAPER_ENV_B4 =             33
Const DMPAPER_ENV_B5 =             34
Const DMPAPER_ENV_B6 =             35
Const DMPAPER_ENV_ITALY =          36
Const DMPAPER_ENV_MONARCH =        37
Const DMPAPER_ENV_PERSONAL =       38
Const DMPAPER_FANFOLD_US =         39
Const DMPAPER_FANFOLD_STD_GERMAN = 40
Const DMPAPER_FANFOLD_LGL_GERMAN = 41
Const DMRES_DRAFT =  -1
Const DMRES_LOW =    -2
Const DMRES_MEDIUM = -3
Const DMRES_HIGH =   -4
Const DMCOLOR_MONOCHROME = 1
Const DMCOLOR_COLOR =      2
Const DMDUP_SIMPLEX =    1
Const DMDUP_VERTICAL =   2
Const DMDUP_HORIZONTAL = 3
Const DMTT_BITMAP =   1
Const DMTT_DOWNLOAD = 2
Const DMTT_SUBDEV =   3
Const DMCOLLATE_FALSE = 0
Const DMCOLLATE_TRUE =  1

Const CCHFORMNAME = 32
Type DEVMODEW
	dmDeviceName[ELM(CCHDEVICENAME)] As WCHAR
	dmSpecVersion As Word
	dmDriverVersion As Word
	dmSize As Word
	dmDriverExtra As Word
	dmFields As DWord
	dmOrientation As Integer
	dmPaperSize As Integer
	dmPaperLength As Integer
	dmPaperWidth As Integer
	dmScale As Integer
	dmCopies As Integer
	dmDefaultSource As Integer
	dmPrintQuality As Integer
	dmColor As Integer
	dmDuplex As Integer
	dmYResolution As Integer
	dmTTOption As Integer
	dmCollate As Integer
	dmFormName[ELM(CCHFORMNAME)] As WCHAR
	dmLogPixels As Word
	dmBitsPerPel As DWord
	dmPelsWidth As DWord
	dmPelsHeight As DWord
	dmDisplayFlags As DWord
	dmDisplayFrequency As DWord
	dmICMMethod As DWord
	dmICMIntent As DWord
	dmMediaType As DWord
	dmDitherType As DWord
	dmReserved1 As DWord
	dmReserved2 As DWord
	dmPanningWidth As DWord
	dmPanningHeight As DWord
End Type
Type DEVMODEA
	dmDeviceName[ELM(CCHDEVICENAME)] As SByte
	dmSpecVersion As Word
	dmDriverVersion As Word
	dmSize As Word
	dmDriverExtra As Word
	dmFields As DWord
	dmOrientation As Integer
	dmPaperSize As Integer
	dmPaperLength As Integer
	dmPaperWidth As Integer
	dmScale As Integer
	dmCopies As Integer
	dmDefaultSource As Integer
	dmPrintQuality As Integer
	dmColor As Integer
	dmDuplex As Integer
	dmYResolution As Integer
	dmTTOption As Integer
	dmCollate As Integer
	dmFormName[ELM(CCHFORMNAME)] As SByte
	dmLogPixels As Word
	dmBitsPerPel As DWord
	dmPelsWidth As DWord
	dmPelsHeight As DWord
	dmDisplayFlags As DWord
	dmDisplayFrequency As DWord
	dmICMMethod As DWord
	dmICMIntent As DWord
	dmMediaType As DWord
	dmDitherType As DWord
	dmReserved1 As DWord
	dmReserved2 As DWord
	dmPanningWidth As DWord
	dmPanningHeight As DWord
End Type
#ifdef UNICODE
TypeDef DEVMODE = DEVMODEW
#else
TypeDef DEVMODE = DEVMODEA
#endif

' Binary raster ops
Const R2_BLACK =       1
Const R2_NOTMERGEPEN = 2
Const R2_MASKNOTPEN =  3
Const R2_NOTCOPYPEN =  4
Const R2_MASKPENNOT =  5
Const R2_NOT =         6
Const R2_XORPEN =      7
Const R2_NOTMASKPEN =  8
Const R2_MASKPEN =     9
Const R2_NOTXORPEN =   10
Const R2_NOP =         11
Const R2_MERGENOTPEN = 12
Const R2_COPYPEN =     13
Const R2_MERGEPENNOT = 14
Const R2_MERGEPEN =    15
Const R2_WHITE =       16


Type RGNDATAHEADER
	dwSize As DWord
	iType As DWord
	nCount As DWord
	nRgnSize As DWord
	rcBound As RECT
End Type
Type RGNDATA
	rdh As RGNDATAHEADER
	Buffer As Byte
End Type

Type PALETTEENTRY
	peRed As Byte
	peGreen As Byte
	peBlue As Byte
	peFlags As Byte
End Type

Type DOCINFOW
	cbSize As Long
	lpszDocName As LPCWSTR
	lpszOutput As LPCWSTR
	lpszDatatype As LPCWSTR
	fwType As DWord
End Type
Type DOCINFOA
	cbSize As Long
	lpszDocName As LPCSTR
	lpszOutput As LPCSTR
	lpszDatatype As LPCSTR
	fwType As DWord
End Type
#ifdef UNICODE
TypeDef DOCINFO = DOCINFOW
#else
TypeDef DOCINFO = DOCINFOA
#endif

'-------------------
' GDI API Functions
'-------------------

Declare Function AbortPath Lib "gdi32" (hdc As HDC) As BOOL
Type BLENDFUNCTION
	BlendOp As Byte
	BlendFlags As Byte
	SourceConstantAlpha As Byte
	AlphaFormat As Byte
End Type
Declare Function AlphaBlend Lib "msimg32" (hdcDest As HDC, nXDest As Long, nYDest As Long, nDestWidth As Long, nDestHeight As Long, hdcSrc As HDC, XSrc As Long, YSrc As Long, nSrcWidth As Long, nSrcHeight As Long, ByRef blendfunc As BLENDFUNCTION) As Long
Declare Function Arc Lib "gdi32" (hdc As HDC, nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long, nXStartArc As Long, nYStartArc As Long, nXEndArc As Long, nYEndArc As Long) As BOOL
Declare Function BeginPath Lib "gdi32" (hdc As HDC) As BOOL
Declare Function BitBlt Lib "gdi32" (hdcDest As HDC, nXDest As Long, nYDest As Long, nWidth As Long, nHeight As Long, hdcSrc As HDC, nXSrc As Long, nYSrc As Long, dwRop As DWord) As BOOL
Declare Function CancelDC Lib "gdi32" (hdc As HDC) As BOOL
Declare Function Chord Lib "gdi32" (hdc As HDC, nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long, nXRadial1 As Long, nYRadial1 As Long, nXRadial2 As Long, nYRadial2 As Long) As BOOL
Declare Function CloseEnhMetaFile Lib "gdi32" (hdc As HDC) As HENHMETAFILE
Declare Function CloseFigure Lib "gdi32" (hdc As HDC) As BOOL
Declare Function CloseMetaFile Lib "gdi32" (hdc As HDC) As HMETAFILE

Const RGN_AND =  1
Const RGN_OR =   2
Const RGN_XOR =  3
Const RGN_DIFF = 4
Const RGN_COPY = 5
Declare Function CombineRgn Lib "gdi32" (hrgnDest As HRGN, hrgnSrc1 As HRGN, hrgnSrc2 As HRGN, fnCombineMode As Long) As Long
Declare Function CopyEnhMetaFile Lib "gdi32" Alias _FuncName_CopyEnhMetaFile (hemfSrc As HENHMETAFILE, pszFile As PCTSTR) As HENHMETAFILE
Declare Function CopyMetaFile Lib "gdi32" Alias _FuncName_CopyMetaFile (hmfSrc As HMETAFILE, pszFile As PCTSTR) As HMETAFILE
Declare Function CreateBitmap Lib "gdi32" (nWidth As Long, nHeight As Long, cPlanes As Long, cBitsPerPel As Long, lpvBits As VoidPtr) As HBITMAP
Declare Function CreateBitmapIndirect Lib "gdi32" (ByRef bm As BITMAP) As HBITMAP

Const BS_SOLID =          0
Const BS_NULL =           1
Const BS_HOLLOW =         BS_NULL
Const BS_HATCHED =        2
Const BS_PATTERN =        3
Const BS_INDEXED =        4
Const BS_DIBPATTERN =     5
Const BS_DIBPATTERNPT =   6
Const BS_PATTERN8X8 =     7
Const BS_DIBPATTERN8X8 =  8
Const BS_MONOPATTERN =    9
Const DIB_RGB_COLORS =    0
Const DIB_PAL_COLORS =    1
Const HS_HORIZONTAL =     0
Const HS_VERTICAL =       1
Const HS_FDIAGONAL =      2
Const HS_BDIAGONAL =      3
Const HS_CROSS =          4
Const HS_DIAGCROSS =      5
Type LOGBRUSH
	lbStyle As Long
	lbColor As Long
	lbHatch As Long
End Type
Declare Function CreateBrushIndirect Lib "gdi32" (ByRef lplb As LOGBRUSH) As HBRUSH

Declare Function CreateCompatibleBitmap Lib "gdi32" (hdc As HDC, nWidth As Long, nHeight As Long) As HBITMAP
Declare Function CreateCompatibleDC Lib "gdi32" (hdc As HDC) As HDC
Declare Function CreateDC Lib "gdi32" Alias _FuncName_CreateDC (pszDriver As PCTSTR, pszDevice As PCTSTR, pszOutput As PCTSTR, ByRef InitData As DEVMODE) As HDC

Const CBM_INIT = &H04
Declare Function CreateDIBitmap Lib "gdi32" (hdc As HDC, ByRef bmih As BITMAPINFOHEADER, fdwInit As Long, lpbInit As VoidPtr, ByRef bmi As BITMAPINFO, fuUsage As Long) As HBITMAP

Declare Function CreateDIBPatternBrushPt Lib "gdi32" (lpPackedDIB As VoidPtr, iUsage As Long) As HBRUSH
Declare Function CreateDIBSection Lib "gdi32" (hdc As HDC, ByRef BmpInfo As BITMAPINFO, iUsage As DWord, ppvBits As *VoidPtr, hSection As HANDLE, dwOffset As DWord) As HBITMAP
Declare Function CreateEllipticRgn Lib "gdi32" (nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long) As HRGN
Declare Function CreateEllipticRgnIndirect Lib "gdi32" (ByRef lpRect As RECT) As HRGN
Declare Function CreateEnhMetaFile Lib "gdi32" Alias _FuncName_CreateEnhMetaFile (hdcRef As HDC, pFileName As PCTSTR, ByRef Rect As RECT, pDescription As PCTSTR) As HDC
Declare Function CreateMetaFile Lib "gdi32" Alias _FuncName_CreateMetaFile (pFileName As PCTSTR) As HDC

Const FW_DONTCARE =       0
Const FW_THIN =           100
Const FW_EXTRALIGHT =     200
Const FW_LIGHT =          300
Const FW_NORMAL =         400
Const FW_MEDIUM =         500
Const FW_SEMIBOLD =       600
Const FW_BOLD =           700
Const FW_EXTRABOLD =      800
Const FW_HEAVY =          900
Const FW_ULTRALIGHT =     FW_EXTRALIGHT
Const FW_REGULAR =        FW_NORMAL
Const FW_DEMIBOLD =       FW_SEMIBOLD
Const FW_ULTRABOLD =      FW_EXTRABOLD
Const FW_BLACK =          FW_HEAVY

Const ANSI_CHARSET =          0
Const DEFAULT_CHARSET =       1
Const SYMBOL_CHARSET =        2
Const SHIFTJIS_CHARSET =      128
Const HANGEUL_CHARSET =       129
Const HANGUL_CHARSET =        129
Const GB2312_CHARSET =        134
Const CHINESEBIG5_CHARSET =   136
Const OEM_CHARSET =           255
Const JOHAB_CHARSET =         130
Const HEBREW_CHARSET =        177
Const ARABIC_CHARSET =        178
Const GREEK_CHARSET =         161
Const TURKISH_CHARSET =       162
Const VIETNAMESE_CHARSET =    163
Const THAI_CHARSET =          222
Const EASTEUROPE_CHARSET =    238
Const RUSSIAN_CHARSET =       204
Const MAC_CHARSET =           77
Const BALTIC_CHARSET =        186

Const OUT_DEFAULT_PRECIS =        0
Const OUT_STRING_PRECIS =         1
Const OUT_CHARACTER_PRECIS =      2
Const OUT_STROKE_PRECIS =         3
Const OUT_TT_PRECIS =             4
Const OUT_DEVICE_PRECIS =         5
Const OUT_RASTER_PRECIS =         6
Const OUT_TT_ONLY_PRECIS =        7
Const OUT_OUTLINE_PRECIS =        8
Const OUT_SCREEN_OUTLINE_PRECIS = 9

Const CLIP_DEFAULT_PRECIS =   0
Const CLIP_CHARACTER_PRECIS = 1
Const CLIP_STROKE_PRECIS =    2
Const CLIP_MASK =             &Hf
Const CLIP_LH_ANGLES =        &H00010000
Const CLIP_TT_ALWAYS =        &H00020000
Const CLIP_EMBEDDED =         &H00080000

Const DEFAULT_QUALITY =       0
Const DRAFT_QUALITY =         1
Const PROOF_QUALITY =         2
Const NONANTIALIASED_QUALITY =3
Const ANTIALIASED_QUALITY =   4

Const DEFAULT_PITCH =         0
Const FIXED_PITCH =           1
Const VARIABLE_PITCH =        2

Const FF_DONTCARE =       0
Const FF_ROMAN =          &H00010000
Const FF_SWISS =          &H00020000
Const FF_MODERN =         &H00030000
Const FF_SCRIPT =         &H00040000
Const FF_DECORATIVE =     &H00050000
Declare Function CreateFont Lib "gdi32" Alias _FuncName_CreateFont (nHeight As Long, nWidth As Long, nEscapement As Long, nOrientation As Long, fnWeight As Long, fdwItalic As DWord, fdwUnderline As DWord, fdwStrikeOut As DWord, fdwCharSet As DWord, fdwOutputPrecision As DWord, fdwClipPrecision As DWord, fdwQuality As DWord, fdwPitchAndFamily As DWord, lpszFace As PCTSTR) As HFONT

Const LF_FACESIZE = 32
Type LOGFONTA
	lfHeight As Long
	lfWidth As Long
	lfEscapement As Long
	lfOrientation As Long
	lfWeight As Long
	lfItalic As Byte
	lfUnderline As Byte
	lfStrikeOut As Byte
	lfCharSet As Byte
	lfOutPrecision As Byte
	lfClipPrecision As Byte
	lfQuality As Byte
	lfPitchAndFamily As Byte
	lfFaceName[ELM(LF_FACESIZE)] As SByte
End Type
Type LOGFONTW
	lfHeight As Long
	lfWidth As Long
	lfEscapement As Long
	lfOrientation As Long
	lfWeight As Long
	lfItalic As Byte
	lfUnderline As Byte
	lfStrikeOut As Byte
	lfCharSet As Byte
	lfOutPrecision As Byte
	lfClipPrecision As Byte
	lfQuality As Byte
	lfPitchAndFamily As Byte
	lfFaceName[ELM(LF_FACESIZE)] As WCHAR
End Type
#ifdef UNICODE
TypeDef LOGFONT = LOGFONTW
#else
TypeDef LOGFONT = LOGFONTA
#endif
Declare Function CreateFontIndirectA Lib "gdi32" (ByRef lf As LOGFONTA) As HFONT
Declare Function CreateFontIndirect Lib "gdi32" Alias _FuncName_CreateFontIndirect (ByRef lf As LOGFONT) As HFONT

Declare Function CreateHatchBrush Lib "gdi32" (fnStyle As Long, clrref As COLORREF) As HBRUSH
Declare Function CreatePatternBrush Lib "gdi32" (hbmp As HBITMAP) As HBRUSH

Const PS_SOLID =       0
Const PS_DASH =        1
Const PS_DOT =         2
Const PS_DASHDOT =     3
Const PS_DASHDOTDOT =  4
Const PS_NULL =        5
Const PS_INSIDEFRAME = 6
Const PS_USERSTYLE =   7
Const PS_ALTERNATE =   8
Declare Function CreatePen Lib "gdi32" (nPenStyle As Long, nWidth As Long, crColor As COLORREF) As HPEN

Type LOGPEN
	lopnStyle As DWord
	lopnWidth As POINTAPI
	lopnColor As COLORREF
End Type
Declare Function CreatePenIndirect Lib "gdi32" (ByRef lplgpn As LOGPEN) As HPEN

Declare Function CreatePolygonRgn Lib "gdi32" (ByRef lpPoints As POINTAPI, cPoints As Long, fnPolyFillMode As Long) As HRGN
Declare Function CreateRectRgn Lib "gdi32" (nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long) As HRGN
Declare Function CreateRectRgnIndirect Lib "gdi32" (ByRef lpRect As RECT) As HRGN
Declare Function CreateRoundRectRgn Lib "gdi32" (nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long, nWidthEllipse As Long, nHeightEllipse As Long) As HRGN
Declare Function CreateSolidBrush Lib "gdi32" (crColor As COLORREF) As HBRUSH
Declare Function DeleteDC Lib "gdi32" (hdc As HDC) As BOOL
Declare Function DeleteEnhMetaFile Lib "gdi32" (hemf As HENHMETAFILE) As BOOL
Declare Function DeleteMetaFile Lib "gdi32" (hmf As HMETAFILE) As BOOL
Declare Function DeleteObject Lib "gdi32" (hObject As HANDLE) As BOOL
Declare Function DPtoLP Lib "gdi32" (hdc As HDC, ByRef lpPoints As POINTAPI, nCount As Long) As BOOL
Declare Function Ellipse Lib "gdi32" (hdc As HDC, nLeftRect As Long, nTopRect As Long, RightRect As Long, nBottomRect As Long) As BOOL
Declare Function EndDoc Lib "gdi32" (hdc As HDC) As Long
Declare Function EndPage Lib "gdi32" (hdc As HDC) As Long
Declare Function EndPath Lib "gdi32" (hdc As HDC) As BOOL
Declare Function EnumEnhMetaFile Lib "gdi32" (hdc As HDC, hemf As HENHMETAFILE, pEnhMetaFunc As ENHMFENUMPROC, pData As VoidPtr, ByRef Rect As RECT) As BOOL
Declare Function EnumMetaFile Lib "gdi32" (hdc As HDC, hmf As HMETAFILE, pMetaFunc As MFENUMPROC, lParam As LPARAM) As BOOL
Declare Function EqualRgn Lib "gdi32" (hSrcRgn1 As HRGN, hSrcRgn2 As HRGN) As BOOL
Declare Function ExcludeClipRect Lib "gdi32" (hdc As HDC, nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long) As Long

Const  FLOODFILLBORDER =  0
Const  FLOODFILLSURFACE = 1
Declare Function ExtFloodFill Lib "gdi32" (hdc As HDC, nXStart As Long, nYStart As Long, crColor As COLORREF, fuFillType As DWord) As BOOL

Const PS_COSMETIC  =     &H00000000
Const PS_GEOMETRIC =     &H00010000
Const PS_ENDCAP_ROUND =  &H00000000
Const PS_ENDCAP_SQUARE = &H00000100
Const PS_ENDCAP_FLAT =   &H00000200
Const PS_JOIN_ROUND =    &H00000000
Const PS_JOIN_BEVEL =    &H00001000
Const PS_JOIN_MITER =    &H00002000
Declare Function ExtCreatePen Lib "gdi32" (dwPenStyle As DWord, dwWidth As DWord, ByRef lplb As LOGBRUSH, dwStyleCount As DWord, lpStyle As *DWord) As HPEN

Declare Function ExtSelectClipRgn Lib "gdi32" (hdc As HDC, hRgn As HRGN, fnMode As Long) As Long
Declare Function ExtTextOutA Lib "gdi32" (hdc As HDC, x As Long, y As Long, fuOptions As DWord, ByRef rc As RECT, lpString As PCSTR, cbCount As Long, pDx As *Long) As Long
Declare Function ExtTextOutW Lib "gdi32" (hdc As HDC, x As Long, y As Long, fuOptions As DWord, ByRef rc As RECT, lpString As PCWSTR, cbCount As Long, pDx As *Long) As Long
#ifdef UNICODE
Declare Function ExtTextOut Lib "gdi32" Alias "ExtTextOutW" (hdc As HDC, x As Long, y As Long, fuOptions As DWord, ByRef rc As RECT, pString As PCWSTR, cbCount As Long, pDx As *Long) As Long
#else
Declare Function ExtTextOut Lib "gdi32" Alias "ExtTextOutA" (hdc As HDC, x As Long, y As Long, fuOptions As DWord, ByRef rc As RECT, pString As PCSTR, cbCount As Long, pDx As *Long) As Long
#endif
Declare Function FillPath Lib "gdi32" (hdc As HDC) As Long
Declare Function FillRgn Lib "gdi32" (hdc As HDC, hRgn As HRGN, hBrush As HBRUSH) As Long
Declare Function FrameRgn Lib "gdi32" (hdc As HDC, hRgn As HRGN, hBrush As HBRUSH, nWidth As Long, nHeight As Long) As Long
Declare Function GdiComment Lib "gdi32" (hdc As HDC, cbSize As DWord, lpData As *Byte) As BOOL
Declare Function GetBitmapBits Lib "gdi32" (hbmp As HBITMAP, cbBuffer As Long, lpvBits As VoidPtr) As Long
Declare Function GetBkColor Lib "gdi32" (hdc As HDC) As DWord
Declare Function GetBkMode Lib "gdi32" (hdc As HDC) As Long
Declare Function GetBrushOrgEx Lib "gdi32" (hdc As HDC, ByRef lppt As POINTAPI) As Long
' only WinNT
'Declare Function GetCharWidth32 Lib "gdi32" Alias "GetCharWidth32A" (hdc As HDC, iFirstChar As DWord, iLastChar As DWord, pBuffer As *DWord) As Long
Declare Function GetClipBox Lib "gdi32" (hdc As HDC, ByRef lpRect As RECT) As Long
Declare Function GetClipRgn Lib "gdi32" (hdc As HDC, hRgn As HRGN) As Long
Declare Function GetCurrentObject Lib "gdi32" (hdc As HDC, dwObjectType As DWord) As HANDLE
Declare Function GetCurrentPositionEx Lib "gdi32" (hdc As HDC, ByRef Point As POINTAPI) As Long

Const DRIVERVERSION =   0
Const TECHNOLOGY =      2
Const HORZSIZE =        4
Const VERTSIZE =        6
Const HORZRES =         8
Const VERTRES =         10
Const BITSPIXEL =       12
Const PLANES =          14
Const NUMBRUSHES =      16
Const NUMPENS =         18
Const NUMMARKERS =      20
Const NUMFONTS =        22
Const NUMCOLORS =       24
Const PDEVICESIZE =     26
Const CURVECAPS =       28
Const LINECAPS =        30
Const POLYGONALCAPS =   32
Const TEXTCAPS =        34
Const CLIPCAPS =        36
Const RASTERCAPS =      38
Const ASPECTX =         40
Const ASPECTY =         42
Const ASPECTXY =        44
Const SHADEBLENDCAPS =  45
Const LOGPIXELSX =      88
Const LOGPIXELSY =      90
Const SIZEPALETTE =     104
Const NUMRESERVED =     106
Const COLORRES =        108
Const PHYSICALWIDTH =   110
Const PHYSICALHEIGHT =  111
Const PHYSICALOFFSETX = 112
Const PHYSICALOFFSETY = 113
Const SCALINGFACTORX =  114
Const SCALINGFACTORY =  115
Const VREFRESH =        116
Const DESKTOPVERTRES =  117
Const DESKTOPHORZRES =  118
Const BLTALIGNMENT =    119
Const DT_PLOTTER =        0            ' Device Technologies
Const DT_RASDISPLAY =     1
Const DT_RASPRINTER =     2
Const DT_RASCAMERA =      3
Const DT_CHARSTREAM =     4
Const DT_METAFILE =       5
Const DT_DISPFILE =       6
Const CC_NONE =           0            ' Curve Capabilities
Const CC_CIRCLES =        1
Const CC_PIE =            2
Const CC_CHORD =          4
Const CC_ELLIPSES =       8
Const CC_WIDE =           16
Const CC_STYLED =         32
Const CC_WIDESTYLED =     64
Const CC_INTERIORS =      128
Const CC_ROUNDRECT =      256
Const LC_NONE =           0            ' Line Capabilities
Const LC_POLYLINE =       2
Const LC_MARKER =         4
Const LC_POLYMARKER =     8
Const LC_WIDE =           16
Const LC_STYLED =         32
Const LC_WIDESTYLED =     64
Const LC_INTERIORS =      128
Const PC_NONE =           0            ' Polygonal Capabilities
Const PC_POLYGON =        1
Const PC_RECTANGLE =      2
Const PC_WINDPOLYGON =    4
Const PC_TRAPEZOID =      4
Const PC_SCANLINE =       8
Const PC_WIDE =           16
Const PC_STYLED =         32
Const PC_WIDESTYLED =     64
Const PC_INTERIORS =      128
Const PC_POLYPOLYGON =    256
Const PC_PATHS =          512
Const CP_NONE =           0            ' Clipping Capabilities
Const CP_RECTANGLE =      1
Const CP_REGION =         2
Const TC_OP_CHARACTER =   &H00000001   ' Text Capabilities
Const TC_OP_STROKE =      &H00000002
Const TC_CP_STROKE =      &H00000004
Const TC_CR_90 =          &H00000008
Const TC_CR_ANY =         &H00000010
Const TC_SF_X_YINDEP =    &H00000020
Const TC_SA_DOUBLE =      &H00000040
Const TC_SA_INTEGER =     &H00000080
Const TC_SA_CONTIN =      &H00000100
Const TC_EA_DOUBLE =      &H00000200
Const TC_IA_ABLE =        &H00000400
Const TC_UA_ABLE =        &H00000800
Const TC_SO_ABLE =        &H00001000
Const TC_RA_ABLE =        &H00002000
Const TC_VA_ABLE =        &H00004000
Const TC_RESERVED =       &H00008000
Const TC_SCROLLBLT =      &H00010000
Const RC_BITBLT =         1            ' Raster Capabilities
Const RC_BANDING =        2
Const RC_SCALING =        4
Const RC_BITMAP64 =       8
Const RC_GDI20_OUTPUT =   &H0010
Const RC_GDI20_STATE =    &H0020
Const RC_SAVEBITMAP =     &H0040
Const RC_DI_BITMAP =      &H0080
Const RC_PALETTE =        &H0100
Const RC_DIBTODEV =       &H0200
Const RC_BIGFONT =        &H0400
Const RC_STRETCHBLT =     &H0800
Const RC_FLOODFILL =      &H1000
Const RC_STRETCHDIB =     &H2000
Const RC_OP_DX_OUTPUT =   &H4000
Const RC_DEVBITS =        &H8000
Const SB_NONE =           &H00000000   ' Shading and blending caps
Const SB_CONST_ALPHA =    &H00000001
Const SB_PIXEL_ALPHA =    &H00000002
Const SB_PREMULT_ALPHA =  &H00000004
Const SB_GRAD_RECT =      &H00000010
Declare Function GetDeviceCaps Lib "gdi32" (hdc As HDC, nIndex As Long) As Long

Declare Function GetDIBits Lib "gdi32" (hdc As HDC, hbmp As HBITMAP, uStartScan As DWord, cScanLines As DWord, lpvBits As VoidPtr, ByRef lpbi As BITMAPINFO, uUsage As DWord) As Long
Declare Function GetEnhMetaFile Lib "gdi32" Alias _FuncName_GetEnhMetaFile (pszMetaFile As PCTSTR) As HENHMETAFILE
Declare Function GetEnhMetaFileBits Lib "gdi32" (hemf As HENHMETAFILE, cbBuffer As DWord, pbBuffer As *Byte) As DWord
Declare Function GetEnhMetaFileDescription Lib "gdi32" Alias _FuncName_GetEnhMetaFileDescription (hemf As HENHMETAFILE, cbBuffer As DWord, pszDescription As PTSTR) As DWord
Declare Function GetEnhMetaFileHeader Lib "gdi32" (hemf As HENHMETAFILE, cbBuffer As DWord, ByRef emh As ENHMETAHEADER) As DWord
Declare Function GetEnhMetaFilePaletteEntries Lib "gdi32" (hemf As HENHMETAFILE, cEntries As DWord, ByRef pe As PALETTEENTRY) As DWord

Const MM_TEXT =           1
Const MM_LOMETRIC =       2
Const MM_HIMETRIC =       3
Const MM_LOENGLISH =      4
Const MM_HIENGLISH =      5
Const MM_TWIPS =          6
Const MM_ISOTROPIC =      7
Const MM_ANISOTROPIC =    8
Declare Function GetMapMode Lib "gdi32" (hdc As HDC) As Long
Declare Function GetMetaFileBitsEx Lib "gdi32" (hmf As HMETAFILE, nSize As DWord, pvData As VoidPtr) As DWord
Declare Function GetMiterLimit Lib "gdi32" (hdc As HDC, peLimit As SinglePtr) As Long
Declare Function GetObject Lib "gdi32" Alias _FuncName_GetObject (hgdiobj As HANDLE, cbBuffer As Long, ByRef pvObject As Any) As Long
Declare Function GetObjectType Lib "gdi32" (hObject As HANDLE) As Long

Const PT_CLOSEFIGURE = &H01
Const PT_LINETO =      &H02
Const PT_BEZIERTO =    &H04
Const PT_MOVETO =      &H06
Declare Function GetPath Lib "gdi32" (hdc As HDC, ByRef lpPoints As POINTAPI, lpTypes As BytePtr, nSize As Long) As Long

Declare Function GetPixel Lib "gdi32" (hdc As HDC, x As Long, y As Long) As DWord
Declare Function GetPolyFillMode Lib "gdi32" (hdc As HDC) As Long
Declare Function GetRgnBox Lib "gdi32" (hRgn As HRGN, ByRef lpRect As RECT) As Long
Declare Function GetROP2 Lib "gdi32" (hdc As HDC) As Long

Const WHITE_BRUSH =         0
Const LTGRAY_BRUSH =        1
Const GRAY_BRUSH =          2
Const DKGRAY_BRUSH =        3
Const BLACK_BRUSH =         4
Const NULL_BRUSH =          5
Const HOLLOW_BRUSH =        NULL_BRUSH
Const WHITE_PEN =           6
Const BLACK_PEN =           7
Const NULL_PEN =            8
Const OEM_FIXED_FONT =      10
Const ANSI_FIXED_FONT =     11
Const ANSI_VAR_FONT =       12
Const SYSTEM_FONT =         13
Const DEVICE_DEFAULT_FONT = 14
Const DEFAULT_PALETTE =     15
Const SYSTEM_FIXED_FONT =   16
Declare Function GetStockObject Lib "gdi32" (fnObject As Long) As HANDLE

Declare Function GetStretchBltMode Lib "gdi32" (hdc As HDC) As Long

Const TA_NOUPDATECP = 0
Const TA_UPDATECP =   1
Const TA_LEFT =       0
Const TA_RIGHT =      2
Const TA_CENTER =     6
Const TA_TOP =        0
Const TA_BOTTOM =     8
Const TA_BASELINE =   24
Const TA_RTLREADING = 256
Declare Function GetTextAlign Lib "gdi32" (hdc As HDC) As DWord

Declare Function GetTextColor Lib "gdi32" (hdc As HDC) As DWord
Declare Function GetTextExtentPoint32A Lib "gdi32" (hdc As HDC, pString As PCSTR, cbString As Long, ByRef Size As SIZE) As Long
Declare Function GetTextExtentPoint32W Lib "gdi32" (hdc As HDC, pString As PCWSTR, cbString As Long, ByRef Size As SIZE) As Long
#ifdef UNICODE
Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32W" (hdc As HDC, pString As PCWSTR, cbString As Long, ByRef Size As SIZE) As Long
#else
Declare Function GetTextExtentPoint32 Lib "gdi32" Alias "GetTextExtentPoint32A" (hdc As HDC, pString As PCSTR, cbString As Long, ByRef Size As SIZE) As Long
#endif
Declare Function GetTextFace Lib "gdi32" Alias _FuncName_GetTextFace (hdc As HDC, nCount As Long, lpFacename As LPTSTR)As Long

Const TMPF_FIXED_PITCH = &H01
Const TMPF_VECTOR =      &H02
Const TMPF_DEVICE =      &H08
Const TMPF_TRUETYPE =    &H04
Type TEXTMETRICW
	tmHeight As Long
	tmAscent As Long
	tmDescent As Long
	tmInternalLeading As Long
	tmExternalLeading As Long
	tmAveCharWidth As Long
	tmMaxCharWidth As Long
	tmWeight As Long
	tmOverhang As Long
	tmDigitizedAspectX As Long
	tmDigitizedAspectY As Long
	tmFirstChar As WCHAR
	tmLastChar As WCHAR
	tmDefaultChar As WCHAR
	tmBreakChar As WCHAR
	tmItalic As Byte
	tmUnderlined As Byte
	tmStruckOut As Byte
	tmPitchAndFamily As Byte
	tmCharSet As Byte
End Type
Type TEXTMETRICA
	tmHeight As Long
	tmAscent As Long
	tmDescent As Long
	tmInternalLeading As Long
	tmExternalLeading As Long
	tmAveCharWidth As Long
	tmMaxCharWidth As Long
	tmWeight As Long
	tmOverhang As Long
	tmDigitizedAspectX As Long
	tmDigitizedAspectY As Long
	tmFirstChar As SByte
	tmLastChar As SByte
	tmDefaultChar As SByte
	tmBreakChar As SByte
	tmItalic As Byte
	tmUnderlined As Byte
	tmStruckOut As Byte
	tmPitchAndFamily As Byte
	tmCharSet As Byte
End Type
#ifdef UNICODE
TypeDef TEXTMETRIC = TEXTMETRICW
#else
TypeDef TEXTMETRIC = TEXTMETRICA
#endif
Declare Function GetTextMetrics Lib "gdi32" Alias _FuncName_GetTextMetrics (hdc As HDC, ByRef tm As TEXTMETRIC) As Long

Declare Function GetViewportExtEx Lib "gdi32" (hdc As HDC, ByRef lpSize As SIZE) As Long
Declare Function GetViewportOrgEx Lib "gdi32" (hdc As HDC, ByRef lpPoint As POINTAPI) As Long
Declare Function GetWindowExtEx Lib "gdi32" (hdc As HDC, ByRef lpSize As SIZE) As Long
Declare Function GetWindowOrgEx Lib "gdi32" (hdc As HDC, ByRef lpPoint As POINTAPI) As Long
Declare Function GetWinMetaFileBits Lib "gdi32" (hemf As HENHMETAFILE, cbBuffer As DWord, pbBuffer As *Byte, fnMapMode As Long, hdcRef As HDC) As DWord
Declare Function IntersectClipRect Lib "gdi32" (hdc As HDC, nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long) As Long
Declare Function InvertRgn Lib "gdi32" (hdc As HDC, hRgn As HRGN) As Long
Declare Function LineTo Lib "gdi32" (hdc As HDC, nXEnd As Long, nYEnd As Long) As Long
Declare Function LPtoDP Lib "gdi32" (hdc As HDC, ByRef lpPoints As POINTAPI, nCount As Long) As Long
Declare Function MoveToEx Lib "gdi32" (hdc As HDC, x As Long, y As Long, ByRef lpPoint As POINTAPI) As Long
Declare Function OffsetRgn Lib "gdi32" (hRgn As HRGN, nXOffset As Long, nYOffset As Long) As Long
Declare Function OffsetClipRgn Lib "gdi32" (hdc As HDC, nXOffset As Long, nYOffset As Long) As Long
Declare Function OffsetViewportOrgEx Lib "gdi32" (hdc As HDC, nXOffset As Long, nYOffset As Long, ByRef lpPoint As POINTAPI) As Long
Declare Function OffsetWindowOrgEx Lib "gdi32" (hdc As HDC, nXOffset As Long, nYOffset As Long, ByRef lpPoint As POINTAPI) As Long
Declare Function PaintRgn Lib "gdi32" (hdc As HDC, hRgn As HRGN) As Long
Declare Function PatBlt Lib "gdi32" (hdc As HDC, nXLeft As Long, nYLeft As Long, nWidth As Long, nHeight As Long, dwRop As DWord) As Long
Declare Function PathToRegion Lib "gdi32" (hdc As HDC) As HRGN
Declare Function Pie Lib "gdi32" (hdc As HDC, nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long, nXRadial1 As Long, nYRadial1 As Long, nXRadial2 As Long, nYRadial2 As Long) As Long
Declare Function PlayEnhMetaFile Lib "gdi32" (hdc As HDC, hemf As HENHMETAFILE, ByRef Rect As RECT) As Long
Declare Function PlayEnhMetaFileRecord Lib "gdi32" (hdc As HDC, ByRef Handletable As HANDLETABLE, ByRef EnhMetaRecord As ENHMETARECORD, nHandles As DWord) As BOOL
Declare Function PlayMetaFile Lib "gdi32" (hdc As HDC, hmf As HMETAFILE) As BOOL
Declare Function PlayMetaFileRecord Lib "gdi32" (hdc As HDC, ByRef Handletable As HANDLETABLE, ByRef MetaRecord As METARECORD, nHandles As DWord) As BOOL
Declare Function PlgBlt Lib "gdi32" (hdcDest As HDC, ByRef lpPoint As POINTAPI, hdcSrc As HDC, nXSrc As Long, nYSrc As Long, nWidth As Long, nHeight As Long, hbmMask As HBITMAP, xMask As Long, yMask As Long) As Long
Declare Function PolyBezier Lib "gdi32" (hdc As HDC, ByRef lppt As POINTAPI, cPoints As Long) As Long
Declare Function PolyBezierTo Lib "gdi32" (hdc As HDC, ByRef lppt As POINTAPI, cPoints As Long) As Long
Declare Function Polygon Lib "gdi32" (hdc As HDC, ByRef lpPoints As POINTAPI, cPoints As Long) As Long
Declare Function Polyline Lib "gdi32" (hdc As HDC, ByRef lppt As POINTAPI, cPoints As Long) As Long
Declare Function PolylineTo Lib "gdi32" (hdc As HDC, ByRef lppt As POINTAPI, cPoints As Long) As Long
Declare Function PtInRegion Lib "gdi32" (hRgn As HRGN, x As Long, y As Long) As Long
Declare Function PtVisible Lib "gdi32" (hdc As HDC, x As Long, y As Long) As Long
Declare Function RealizePalette Lib "gdi32" (hdc As HDC) As Long
Declare Function Rectangle Lib "gdi32" (hdc As HDC, nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long) As Long
Declare Function RectInRegion Lib "gdi32" (hRgn As HRGN, ByRef lpRect As RECT) As Long
Declare Function RectVisible Lib "gdi32" (hdc As HDC, ByRef lpRect As RECT) As Long
Declare Function ResetDC Lib "gdi32" Alias _FuncName_ResetDC (hdc As HDC, ByRef InitData As DEVMODE) As HDC
Declare Function RestoreDC Lib "gdi32" (hdc As HDC, nSavedDC As Long) As Long
Declare Function RoundRect Lib "gdi32" (hdc As HDC, nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long, nWidth As Long, nHeight As Long) As Long
Declare Function SaveDC Lib "gdi32" (hdc As HDC) As Long
Declare Function ScaleViewportExtEx Lib "gdi32" (hdc As HDC, Xnum As Long, Xdenom As Long, Ynum As Long, Ydenom As Long, ByRef lpSize As SIZE) As Long
Declare Function ScaleWindowExtEx Lib "gdi32" (hdc As HDC, Xnum As Long, Xdenom As Long, Ynum As Long, Ydenom As Long, ByRef lpSize As SIZE) As Long
Declare Function SelectClipPath Lib "gdi32" (hdc As HDC, iMode As Long) As Long
Declare Function SelectClipRgn Lib "gdi32" (hdc As HDC, hRgn As HRGN) As Long
Declare Function SelectObject Lib "gdi32" (hdc As HDC, hObject As HANDLE) As HANDLE
Declare Function SelectPalette  Lib "gdi32" (hdc As HDC, hpal As HPALETTE, bForceBackground As BOOL) As HPALETTE
Declare Function SetBkColor Lib "gdi32" (hdc As HDC, crColor As DWord) As DWord

Const TRANSPARENT = 1
Const OPAQUE =      2
Declare Function SetBkMode Lib "gdi32" (hdc As HDC, iBkMode As Long) As Long

Declare Function SetBrushOrgEx Lib "gdi32" (hdc As HDC, nXOrg As Long, nYOrg As Long, ByRef lppt As POINTAPI) As Long
Declare Function SetDIBits Lib "gdi32" (hdc As HDC, hbmp As HBITMAP, uStartScan As DWord, cScanLines As DWord, lpvBits As VoidPtr, ByRef lpbmi As BITMAPINFO, fuColorUse As DWord) As Long
Declare Function SetEnhMetaFileBits Lib "gdi32" (cbBuffer As DWord, pData As *Byte) As HENHMETAFILE
Declare Function SetMapMode Lib "gdi32" (hdc As HDC, fnMapMode As Long) As Long
Declare Function SetMetaFileBitsEx Lib "gdi32" (nSize As DWord, pData As *Byte) As HMETAFILE
Declare Function SetMiterLimit Lib "gdi32" (hdc As HDC, eNewLimit As Single, peOldLimit As SinglePtr) As Long
Declare Function SetPixel Lib "gdi32" (hdc As HDC, x As Long, y As Long, crColor As DWord) As DWord
Declare Function SetPolyFillMode Lib "gdi32" (hdc As HDC, iPolyFillMode As Long) As Long
Declare Function SetRectRgn Lib "gdi32" (hRgn As HRGN, nLeftRect As Long, nTopRect As Long, nRightRect As Long, nBottomRect As Long) As Long
Declare Function SetROP2 Lib "gdi32" (hdc As HDC, fnDrawMode As Long) As Long

Const BLACKONWHITE =        1
Const WHITEONBLACK =        2
Const COLORONCOLOR =        3
Const HALFTONE =            4
Const STRETCH_ANDSCANS =    BLACKONWHITE
Const STRETCH_ORSCANS =     WHITEONBLACK
Const STRETCH_DELETESCANS = COLORONCOLOR
Const STRETCH_HALFTONE =    HALFTONE
Declare Function SetStretchBltMode Lib "gdi32" (hdc As HDC, iStretchMode As Long) As Long

Declare Function SetTextAlign Lib "gdi32" (hdc As HDC, fMode As DWord) As DWord
Declare Function SetTextColor Lib "gdi32" (hdc As HDC, crColor As DWord) As DWord
Declare Function SetViewportExtEx Lib "gdi32" (hdc As HDC, nXExtent As Long, nYExtent As Long, ByRef lpSize As SIZE) As Long
Declare Function SetViewportOrgEx Lib "gdi32" (hdc As HDC, x As Long, y As Long, ByRef lpPoint As POINTAPI) As Long
Declare Function SetWindowExtEx Lib "gdi32" (hdc As HDC, nXExtent As Long, nYExtent As Long, ByRef lpSize As SIZE) As Long
Declare Function SetWindowOrgEx Lib "gdi32" (hdc As HDC, x As Long, y As Long, ByRef lpPoint As POINTAPI) As Long
Declare Function SetWinMetaFileBits Lib "gdi32" (cbBuffer As DWord, pbBuffer As *Byte, hdcRef As HDC, ByRef mfp As METAFILEPICT) As HENHMETAFILE
Declare Function StartDoc Lib "gdi32" Alias _FuncName_StartDoc (hdc As HDC, ByRef di As DOCINFO) As Long
Declare Function StartPage Lib "gdi32" (hdc As HDC) As Long
Declare Function StretchBlt Lib "gdi32" (hdcDest As HDC, nXOriginDest As Long, nYOriginDest As Long, nWidthDest As Long, nHeightDest As Long, hdcSrc As HDC, nXOriginSrc As Long, nYOriginSrc As Long, nWidthSrc As Long, nHeightSrc As Long, dwRop As DWord) As Long
Declare Function StretchDIBits Lib "gdi32" (hdc As HDC, XDest As Long, YDest As Long, nDestWidth As Long, nDestHeight As Long, XSrc As Long, YSrc As Long, nSrcWidth As Long, nSrcHeight As Long, lpBits As VoidPtr, ByRef lpBitsInfo As BITMAPINFO, iUsage As Long, dwRop As DWord) As Long
Declare Function StrokeAndFillPath Lib "gdi32" (hdc As HDC) As Long
Declare Function StrokePath Lib "gdi32" (DC As DWord) As Long
Declare Function TextOutA Lib "gdi32" (hdc As HDC, nXStart As Long, nYStart As Long, pString As PCSTR, cbString As Long) As Long
Declare Function TextOutW Lib "gdi32" (hdc As HDC, nXStart As Long, nYStart As Long, pString As PCWSTR, cbString As Long) As Long
#ifdef UNICODE
Declare Function TextOut Lib "gdi32" Alias "TextOutW" (hdc As HDC, nXStart As Long, nYStart As Long, pString As PCWSTR, cbString As Long) As Long
#else
Declare Function TextOut Lib "gdi32" Alias "TextOutA" (hdc As HDC, nXStart As Long, nYStart As Long, pString As PCSTR, cbString As Long) As Long
#endif
 Declare Function TransparentBlt Lib "msimg32" (hdcDest As HDC, nXDest As Long, nYDest As Long, nDestWidth As Long, nDestHeight As Long, hdcSrc As HDC, XSrc As Long, YSrc As Long, nSrcWidth As Long, nSrcHeight As Long, dwRop As DWord) As Long

/* Pixel Format */
Type PIXELFORMATDESCRIPTOR
	nSize As Word
	nVersion As Word
	dwFlags As DWord
	iPixelType As Byte
	cColorBits As Byte
	cRedBits As Byte
	cRedShift As Byte
	cGreenBits As Byte
	cGreenShift As Byte
	cBlueBits As Byte
	cBlueShift As Byte
	cAlphaBits As Byte
	cAlphaShift As Byte
	cAccumBits As Byte
	cAccumRedBits As Byte
	cAccumGreenBits As Byte
	cAccumBlueBits As Byte
	cAccumAlphaBits As Byte
	cDepthBits As Byte
	cStencilBits As Byte
	cAuxBuffers As Byte
	iLayerType As Byte
	bReserved As Byte
	dwLayerMask As DWord
	dwVisibleMask As DWord
	dwDamageMask As DWord
End Type
TypeDef PPIXELFORMATDESCRIPTOR = *PIXELFORMATDESCRIPTOR
TypeDef LPPIXELFORMATDESCRIPTOR = *PIXELFORMATDESCRIPTOR

Const PFD_TYPE_RGBA = 0
Const PFD_TYPE_COLORINDEX = 1

Const PFD_MAIN_PLANE = 0
Const PFD_OVERLAY_PLANE = 1
Const PFD_UNDERLAY_PLANE = (-1)

Const PFD_DOUBLEBUFFER = &H00000001
Const PFD_STEREO = &H00000002
Const PFD_DRAW_TO_WINDOW = &H00000004
Const PFD_DRAW_TO_BITMAP = &H00000008
Const PFD_SUPPORT_GDI = &H00000010
Const PFD_SUPPORT_OPENGL = &H00000020
Const PFD_GENERIC_FORMAT = &H00000040
Const PFD_NEED_PALETTE = &H00000080
Const PFD_NEED_SYSTEM_PALETTE = &H00000100
Const PFD_SWAP_EXCHANGE = &H00000200
Const PFD_SWAP_COPY = &H00000400
Const PFD_SWAP_LAYER_BUFFERS = &H00000800
Const PFD_GENERIC_ACCELERATED = &H00001000
Const PFD_SUPPORT_DIRECTDRAW = &H00002000

Const PFD_DEPTH_DONTCARE = &H20000000
Const PFD_DOUBLEBUFFER_DONTCARE = &H40000000
Const PFD_STEREO_DONTCARE = &H80000000

Declare Function ChoosePixelFormat Lib "gdi32" (hdc As HDC, ByRef lppfd As PIXELFORMATDESCRIPTOR) As Long
Declare Function DescribePixelFormat Lib "gdi32" (hdc As HDC, n As Long, u As DWord, ByRef lppfd As PIXELFORMATDESCRIPTOR) As Long
Declare Function GetPixelFormat Lib "gdi32" (hdc As HDC) As Long
Declare Function SetPixelFormat Lib "gdi32" (hdc As HDC, i As Long, ByRef lppfd As PIXELFORMATDESCRIPTOR) As BOOL


/* OpenGL Support */

Declare Function wglCopyContext Lib "opengl32" (hglrcSource As HGLRC, hglrcDest As HGLRC, mask As DWord) As BOOL
Declare Function wglCreateContext Lib "opengl32" (hdc As HDC) As HGLRC
Declare Function wglCreateLayerContext Lib "opengl32" (hdc As HDC, iLayerPlane As Long) As HGLRC
Declare Function wglDeleteContext Lib "opengl32" (hglrc As HGLRC) As BOOL
Declare Function wglGetCurrentContext Lib "opengl32" () As HGLRC
Declare Function wglGetCurrentDC Lib "opengl32" () As HDC
Declare Function wglGetProcAddress Lib "opengl32" (lpstr As LPSTR) As PROC
Declare Function wglMakeCurrent Lib "opengl32" (hdc As HDC, hglrc As HGLRC) As BOOL
Declare Function wglShareLists Lib "opengl32" (hglrc1 As HGLRC, hglrc2 As HGLRC) As BOOL
Declare Function wglUseFontBitmaps Lib "opengl32" Alias _FuncName_wglUseFontBitmaps (hdc As HDC, first As DWord, count As DWord, listbase As DWord) As BOOL
Declare Function SwapBuffers Lib "gdi32" (hdc As HDC) As BOOL

Type POINTFLOAT
	x As Single
	y As Single
End Type
TypeDef PPOINTFLOAT = *POINTFLOAT

Type GLYPHMETRICSFLOAT
	gmfBlackBoxX As Single
	gmfBlackBoxY As Single
	gmfptGlyphOrigin As POINTFLOAT
	gmfCellIncX As Single
	gmfCellIncY As Single
End Type
TypeDef PGLYPHMETRICSFLOAT = *GLYPHMETRICSFLOAT
TypeDef LPGLYPHMETRICSFLOAT = *GLYPHMETRICSFLOAT

Const WGL_FONT_LINES = 0
Const WGL_FONT_POLYGONS = 1

Declare Function wglUseFontOutlines Lib "opengl32" Alias _FuncName_wglUseFontOutlines (hdc As HDC, first As DWord, count As DWord, listbase As DWord, deviation As Single, extrusion As Single, format As Long, ByRef lpgmf As GLYPHMETRICSFLOAT) As BOOL

Type LAYERPLANEDESCRIPTOR
	nSize As Word
	nVersion As Word
	dwFlags As DWord
	iPixelType As Byte
	cColorBits As Byte
	cRedBits As Byte
	cRedShift As Byte
	cGreenBits As Byte
	cGreenShift As Byte
	cBlueBits As Byte
	cBlueShift As Byte
	cAlphaBits As Byte
	cAlphaShift As Byte
	cAccumBits As Byte
	cAccumRedBits As Byte
	cAccumGreenBits As Byte
	cAccumBlueBits As Byte
	cAccumAlphaBits As Byte
	cDepthBits As Byte
	cStencilBits As Byte
	cAuxBuffers As Byte
	iLayerPlane As Byte
	bReserved As Byte
	crTransparent As COLORREF
End Type
TypeDef PLAYERPLANEDESCRIPTOR = *LAYERPLANEDESCRIPTOR
TypeDef LPLAYERPLANEDESCRIPTOR = *LAYERPLANEDESCRIPTOR

Const LPD_DOUBLEBUFFER = &H00000001
Const LPD_STEREO = &H00000002
Const LPD_SUPPORT_GDI = &H00000010
Const LPD_SUPPORT_OPENGL = &H00000020
Const LPD_SHARE_DEPTH = &H00000040
Const LPD_SHARE_STENCIL = &H00000080
Const LPD_SHARE_ACCUM = &H00000100
Const LPD_SWAP_EXCHANGE = &H00000200
Const LPD_SWAP_COPY = &H00000400
Const LPD_TRANSPARENT = &H00001000
Const LPD_TYPE_RGBA = 0
Const LPD_TYPE_COLORINDEX = 1

Const WGL_SWAP_MAIN_PLANE = &H00000001
Const WGL_SWAP_OVERLAY1 = &H00000002
Const WGL_SWAP_OVERLAY2 = &H00000004
Const WGL_SWAP_OVERLAY3 = &H00000008
Const WGL_SWAP_OVERLAY4 = &H00000010
Const WGL_SWAP_OVERLAY5 = &H00000020
Const WGL_SWAP_OVERLAY6 = &H00000040
Const WGL_SWAP_OVERLAY7 = &H00000080
Const WGL_SWAP_OVERLAY8 = &H00000100
Const WGL_SWAP_OVERLAY9 = &H00000200
Const WGL_SWAP_OVERLAY10 = &H00000400
Const WGL_SWAP_OVERLAY11 = &H00000800
Const WGL_SWAP_OVERLAY12 = &H00001000
Const WGL_SWAP_OVERLAY13 = &H00002000
Const WGL_SWAP_OVERLAY14 = &H00004000
Const WGL_SWAP_OVERLAY15 = &H00008000
Const WGL_SWAP_UNDERLAY1 = &H00010000
Const WGL_SWAP_UNDERLAY2 = &H00020000
Const WGL_SWAP_UNDERLAY3 = &H00040000
Const WGL_SWAP_UNDERLAY4 = &H00080000
Const WGL_SWAP_UNDERLAY5 = &H00100000
Const WGL_SWAP_UNDERLAY6 = &H00200000
Const WGL_SWAP_UNDERLAY7 = &H00400000
Const WGL_SWAP_UNDERLAY8 = &H00800000
Const WGL_SWAP_UNDERLAY9 = &H01000000
Const WGL_SWAP_UNDERLAY10 = &H02000000
Const WGL_SWAP_UNDERLAY11 = &H04000000
Const WGL_SWAP_UNDERLAY12 = &H08000000
Const WGL_SWAP_UNDERLAY13 = &H10000000
Const WGL_SWAP_UNDERLAY14 = &H20000000
Const WGL_SWAP_UNDERLAY15 = &H40000000

Declare Function wglDescribeLayerPlane Lib "opengl32" (hdc As HDC, iPixelFormat As Long, iLayerPlane As Long, nByte As DWord, ByRef lplpd As LAYERPLANEDESCRIPTOR) As BOOL
Declare Function wglSetLayerPaletteEntries Lib "opengl32" (hdc As HDC, iLayerPlane As Long, iStart As Long, cEntries As Long, lpcr As *COLORREF) As Long
Declare Function wglGetLayerPaletteEntries Lib "opengl32" (hdc As HDC, iLayerPlane As Long, iStart As Long, cEntries As Long, lpcr As *COLORREF) As Long
Declare Function wglRealizeLayerPalette Lib "opengl32" (hdc As HDC, iLayerPlane As Long, bRealize As BOOL) As BOOL
Declare Function wglSwapLayerBuffers Lib "opengl32" (hdc As HDC, fuPlanes As DWord) As BOOL

Type WGLSWAP
	hdc As HDC
	uiFlags As DWord
End Type
TypeDef PWGLSWAP = *WGLSWAP
TypeDef LPWGLSWAP = *WGLSWAP

Const WGL_SWAPMULTIPLE_MAX = 16

'Declare Function wglSwapMultipleBuffers Lib "opengl32" (u As DWord, lpwglswap As *WGLSWAP) As DWord

#endif '_INC_GDI
