vbAccelerator - Contents of code file: GDI_API.bas

Attribute VB_Name = "mGDI_API"
Option Explicit
    
' General:
Declare Function GetWindowWord Lib "user32" (ByVal hwnd As Long, ByVal nIndex
 As Long) As Integer
    Public Const GWW_HINSTANCE = (-6)
    
' GDI object functions:
Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As
 Long) As Long
Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Declare Function GetObjectAPI Lib "gdi32" Alias "GetObjectA" (ByVal hObject As
 Long, ByVal nCount As Long, lpObject As Any) As Long
Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long)
 As Long
Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal
 nWidth As Long, ByVal nHeight As Long) As Long
Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As
 Long) As Long
    Public Const BITSPIXEL = 12
    Public Const LOGPIXELSX = 88    '  Logical pixels/inch in X
    Public Const LOGPIXELSY = 90    '  Logical pixels/inch in Y
' System metrics:
Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    Public Const SM_CXICON = 11
    Public Const SM_CYICON = 12
    Public Const SM_CXFRAME = 32
    Public Const SM_CYCAPTION = 4
    Public Const SM_CYFRAME = 33
    Public Const SM_CYBORDER = 6
    Public Const SM_CXBORDER = 5

' Region paint and fill functions:
Declare Function PaintRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As Long)
 As Long
Declare Function ExtFloodFill Lib "gdi32" (ByVal hdc As Long, ByVal x As Long,
 ByVal y As Long, ByVal crColor As Long, ByVal wFillType As Long) As Long
    Public Const FLOODFILLBORDER = 0
    Public Const FLOODFILLSURFACE = 1
Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long,
 ByVal y As Long) As Long

' Pen functions:
Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth
 As Long, ByVal crColor As Long) As Long
Type LOGBRUSH
   lbStyle As Long
   lbColor As Long
   lbHatch As Long
End Type
Declare Function ExtCreatePen Lib "gdi32" (ByVal dwPenStyle As Long, ByVal
 dwWidth As Long, lplb As LOGBRUSH, ByVal dwStyleCount As Long, lpStyle As
 Long) As Long
Public Const PS_ALTERNATE = 8
Public Const PS_COSMETIC = &H0
Public Const PS_DASH = 1                    '  -------
Public Const PS_DASHDOT = 3                 '  _._._._
Public Const PS_DASHDOTDOT = 4              '  _.._.._
Public Const PS_DOT = 2                     '  .......
Public Const PS_ENDCAP_FLAT = &H200
Public Const PS_ENDCAP_MASK = &HF00
Public Const PS_ENDCAP_ROUND = &H0
Public Const PS_ENDCAP_SQUARE = &H100
Public Const PS_GEOMETRIC = &H10000
Public Const PS_INSIDEFRAME = 6
Public Const PS_JOIN_BEVEL = &H1000
Public Const PS_JOIN_MASK = &HF000
Public Const PS_JOIN_MITER = &H2000
Public Const PS_JOIN_ROUND = &H0
Public Const PS_NULL = 5
Public Const PS_SOLID = 0
Public Const PS_STYLE_MASK = &HF
Public Const PS_TYPE_MASK = &HF0000
Public Const PS_USERSTYLE = 7
Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function CloseFigure Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function StrokePath Lib "gdi32" (ByVal hdc As Long) As Long


' Brush functions:
Declare Function CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long
Declare Function CreatePatternBrush Lib "gdi32" (ByVal hBitmap As Long) As Long

' Line functions:
Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal
 y As Long) As Long
Type POINTAPI
        x As Long
        y As Long
End Type
Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long,
 ByVal y As Long, lpPoint As POINTAPI) As Long

' Colour functions:
Declare Function SetTextColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As
 Long) As Long
Declare Function SetBkColor Lib "gdi32" (ByVal hdc As Long, ByVal crColor As
 Long) As Long
Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As
 Long) As Long
    Public Const OPAQUE = 2
    Public Const TRANSPARENT = 1
Declare Function GetSysColor Lib "user32" (ByVal nIndex As Long) As Long
    Public Const COLOR_ACTIVEBORDER = 10
    Public Const COLOR_ACTIVECAPTION = 2
    Public Const COLOR_ADJ_MAX = 100
    Public Const COLOR_ADJ_MIN = -100
    Public Const COLOR_APPWORKSPACE = 12
    Public Const COLOR_BACKGROUND = 1
    Public Const COLOR_BTNFACE = 15
    Public Const COLOR_BTNHIGHLIGHT = 20
    Public Const COLOR_BTNSHADOW = 16
    Public Const COLOR_BTNTEXT = 18
    Public Const COLOR_CAPTIONTEXT = 9
    Public Const COLOR_GRAYTEXT = 17
    Public Const COLOR_HIGHLIGHT = 13
    Public Const COLOR_HIGHLIGHTTEXT = 14
    Public Const COLOR_INACTIVEBORDER = 11
    Public Const COLOR_INACTIVECAPTION = 3
    Public Const COLOR_INACTIVECAPTIONTEXT = 19
    Public Const COLOR_MENU = 4
    Public Const COLOR_MENUTEXT = 7
    Public Const COLOR_SCROLLBAR = 0
    Public Const COLOR_WINDOW = 5
    Public Const COLOR_WINDOWFRAME = 6
    Public Const COLOR_WINDOWTEXT = 8
    Public Const COLORONCOLOR = 3

' Shell Extract icon functions:
Declare Function FindExecutable Lib "shell32.dll" Alias "FindExecutableA"
 (ByVal lpFile As String, ByVal lpDirectory As String, ByVal lpResult As
 String) As Long
Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal
 hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As
 Long

' Icon functions:
Declare Function DrawIcon Lib "user32" (ByVal hdc As Long, ByVal x As Long,
 ByVal y As Long, ByVal hIcon As Long) As Long
Declare Function DestroyIcon Lib "user32" (ByVal hIcon As Long) As Long
Declare Function DrawIconEx Lib "user32" (ByVal hdc As Long, ByVal xLeft As
 Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal
 cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As
 Long, ByVal diFlags As Long) As Boolean
Declare Function LoadImage Lib "user32" Alias "LoadImageA" (ByVal hInst As
 Long, ByVal lpsz As String, ByVal un1 As Long, ByVal n1 As Long, ByVal n2 As
 Long, ByVal un2 As Long) As Long
    Public Const LR_LOADMAP3DCOLORS = &H1000
    Public Const LR_LOADFROMFILE = &H10
    Public Const LR_LOADTRANSPARENT = &H20

' Blitting functions
Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long,
 ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As
 Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    Public Const SRCAND = &H8800C6
    Public Const SRCCOPY = &HCC0020
    Public Const SRCERASE = &H440328
    Public Const SRCINVERT = &H660046
    Public Const SRCPAINT = &HEE0086
    Public Const BLACKNESS = &H42
    Public Const WHITENESS = &HFF0062
Declare Function PatBlt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal
 y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal dwRop As Long)
 As Long
Declare Function LoadBitmapBynum Lib "user32" Alias "LoadBitmapA" (ByVal
 hInstance As Long, ByVal lpBitmapName As Long) As Long
Type BITMAP '14 bytes
    bmType As Long
    bmWidth As Long
    bmHeight As Long
    bmWidthBytes As Long
    bmPlanes As Integer
    bmBitsPixel As Integer
    bmBits As Long
End Type
Declare Function CreateBitmapIndirect Lib "gdi32" (lpBitmap As BITMAP) As Long

' Text functions:
Type RECT
    left As Long
    tOp As Long
    Right As Long
    Bottom As Long
End Type
Declare Function PtInRect Lib "user32" (lpRect As RECT, ByVal ptX As Long,
 ByVal ptY As Long) As Long
Declare Function InflateRect Lib "user32" (lpRect As RECT, ByVal x As Long,
 ByVal y As Long) As Long
Declare Function Rectangle Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long,
 ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function DrawText Lib "user32" Alias "DrawTextA" (ByVal hdc As Long,
 ByVal lpStr As String, ByVal nCount As Long, lpRect As RECT, ByVal wFormat As
 Long) As Long
    Public Const DT_BOTTOM = &H8
    Public Const DT_CENTER = &H1
    Public Const DT_LEFT = &H0
    Public Const DT_CALCRECT = &H400
    Public Const DT_WORDBREAK = &H10
    Public Const DT_VCENTER = &H4
    Public Const DT_TOP = &H0
    Public Const DT_TABSTOP = &H80
    Public Const DT_SINGLELINE = &H20
    Public Const DT_RIGHT = &H2
    Public Const DT_NOCLIP = &H100
    Public Const DT_INTERNAL = &H1000
    Public Const DT_EXTERNALLEADING = &H200
    Public Const DT_EXPANDTABS = &H40
    Public Const DT_CHARSTREAM = 4
    Public Const DT_NOPREFIX = &H800
Type DRAWTEXTPARAMS
    cbSize As Long
    iTabLength As Long
    iLeftMargin As Long
    iRightMargin As Long
    uiLengthDrawn As Long
End Type
Declare Function DrawTextEx Lib "user32" Alias "DrawTextExA" (ByVal hdc As
 Long, ByVal lpsz As String, ByVal n As Long, lpRect As RECT, ByVal un As Long,
 lpDrawTextParams As DRAWTEXTPARAMS) As Long
Declare Function DrawTextExAsNull Lib "user32" Alias "DrawTextExA" (ByVal hdc
 As Long, ByVal lpsz As String, ByVal n As Long, lpRect As RECT, ByVal un As
 Long, ByVal lpDrawTextParams As Long) As Long
    Public Const DT_EDITCONTROL = &H2000
    Public Const DT_PATH_ELLIPSIS = &H4000
    Public Const DT_END_ELLIPSIS = &H8000
    Public Const DT_MODIFYSTRING = &H10000
    Public Const DT_RTLREADING = &H20000
    Public Const DT_WORD_ELLIPSIS = &H40000

Type SIZEAPI
    cx As Long
    cy As Long
End Type
Public Declare Function GetTextExtentPoint32 Lib "gdi32" Alias
 "GetTextExtentPoint32A" (ByVal hdc As Long, ByVal lpsz As String, ByVal
 cbString As Long, lpSize As SIZEAPI) As Long
Public Declare Function GetStockObject Lib "gdi32" (ByVal nIndex As Long) As
 Long
    Public Const ANSI_FIXED_FONT = 11
    Public Const ANSI_VAR_FONT = 12
    Public Const SYSTEM_FONT = 13
    Public Const DEFAULT_GUI_FONT = 17 'win95 only
Declare Function FillRect Lib "user32" (ByVal hdc As Long, lpRect As RECT,
 ByVal hBrush As Long) As Long
Declare Function DrawEdge Lib "user32" (ByVal hdc As Long, qrc As RECT, ByVal
 edge As Long, ByVal grfFlags As Long) As Long
    Public Const BF_LEFT = 1
    Public Const BF_TOP = 2
    Public Const BF_RIGHT = 4
    Public Const BF_BOTTOM = 8
    Public Const BF_RECT = BF_LEFT Or BF_TOP Or BF_RIGHT Or BF_BOTTOM
    Public Const BF_MIDDLE = 2048
    Public Const BDR_SUNKENINNER = 8
    Public Const BDR_SUNKENOUTER = 2

Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As
 Long) As Long
    Public Const SW_SHOWNOACTIVATE = 4

' Scrolling and region functions:
Declare Function ScrollDC Lib "user32" (ByVal hdc As Long, ByVal dx As Long,
 ByVal dy As Long, lprcScroll As RECT, lprcClip As RECT, ByVal hrgnUpdate As
 Long, lprcUpdate As RECT) As Long
Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As
 Long, ByVal bRedraw As Long) As Long
Declare Function SelectClipRgn Lib "gdi32" (ByVal hdc As Long, ByVal hRgn As
 Long) As Long
Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long,
 ByVal X2 As Long, ByVal Y2 As Long) As Long
Declare Function CreateRectRgnIndirect Lib "gdi32" (lpRect As RECT) As Long
Declare Function CreatePolyPolygonRgn Lib "gdi32" (lpPoint As POINTAPI,
 lpPolyCounts As Long, ByVal nCount As Long, ByVal nPolyFillMode As Long) As
 Long
Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, ByVal
 nCount As Long, ByVal nPolyFillMode As Long)
Declare Function SaveDC Lib "gdi32" (ByVal hdc As Long) As Long
Declare Function RestoreDC Lib "gdi32" (ByVal hdc As Long, ByVal hSavedDC As
 Long) As Long

Public Const LF_FACESIZE = 32
Type LOGFONT
    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(LF_FACESIZE) As Byte
End Type
Public Const FW_NORMAL = 400
Public Const FW_BOLD = 700
Public Const FF_DONTCARE = 0
Public Const DEFAULT_QUALITY = 0
Public Const DEFAULT_PITCH = 0
Public Const DEFAULT_CHARSET = 1
Declare Function CreateFontIndirect& Lib "gdi32" Alias "CreateFontIndirectA"
 (lpLogFont As LOGFONT)
Declare Function MulDiv Lib "kernel32" (ByVal nNumber As Long, ByVal nNumerator
 As Long, ByVal nDenominator As Long) As Long
Declare Function DrawFocusRect Lib "user32" (ByVal hdc As Long, lpRect As RECT)
 As Long

Declare Function OleTranslateColor Lib "OLEPRO32.DLL" (ByVal OLE_COLOR As Long,
 ByVal HPALETTE As Long, pccolorref As Long) As Long
Public Const CLR_INVALID = -1