' ------------------------------------------------------------------------
'
'    WIN31EXT.TXT -- Windows 3.1 API Declarations for Visual Basic
'
'              Copyright (C) 1993 Microsoft Corporation
'
'
'  This file contains the Const, Type, and Declare statements for
'  Windows 3.1 APIs.  If you only want to reference Windows 3.0 APIs,
'  use WIN30API.TXT.
'
'  You must use this file together with WIN30API.TXT in Visual Basic
'  if you want the references to match up properly.
'
'  You have a royalty-free right to use, modify, reproduce and distribute
'  this file (and/or any modified version) in any way you find useful,
'  provided that you agree that Microsoft has no warranty, obligation or
'  liability for its contents.  Refer to the Microsoft Windows Programmer's
'  Reference for further information.
'
'*************************** Windows 3.1 Extensions ***************************
' Window 3.1 commands to pass WinHelp()
Global Const HELP_CONTENTS = &H3     ' Display Help for a particular topic
Global Const HELP_SETCONTENTS = &H5  ' Display Help contents topic
Global Const HELP_CONTEXTPOPUP = &H8 ' Display Help topic in popup window
Global Const HELP_FORCEFILE = &H9    ' Ensure correct Help file is displayed
Global Const HELP_COMMAND = &H102    ' Execute Help macro
Global Const HELP_PARTIALKEY = &H105 ' Display topic found in keyword list
Global Const HELP_SETWINPOS = &H203  ' Display and position Help window

Declare Function GetFreeSystemResources Lib "User" (ByVal fuSysResource As Integer) As Integer

Global Const GFSR_SYSTEMRESOURCES = &H0000
Global Const GFSR_GDIRESOURCES = &H0001
Global Const GFSR_USERRESOURCES = &H0002

Declare Sub LogError Lib "Kernel" (ByVal uErr As Integer, lpvInfo As Any)


' ***** LogParamError/LogError values *****

' Error modifier bits 
Global Const ERR_WARNING = &H8000
Global Const ERR_PARAM = &H4000

Global Const ERR_SIZE_MASK = &H3000
Global Const ERR_BYTE = &H1000
Global Const ERR_WORD = &H2000
Global Const ERR_DWORD = &H3000


' ***** LogParamError() values *****

' Generic parameter values 
Global Const ERR_BAD_VALUE = &H6001
Global Const ERR_BAD_FLAGS = &H6002
Global Const ERR_BAD_INDEX = &H6003
Global Const ERR_BAD_DVALUE = &H7004
Global Const ERR_BAD_DFLAGS = &H7005
Global Const ERR_BAD_DINDEX = &H7006
Global Const ERR_BAD_PTR = &H7007
Global Const ERR_BAD_FUNC_PTR = &H7008
Global Const ERR_BAD_SELECTOR = &H6009
Global Const ERR_BAD_STRING_PTR = &H700a
Global Const ERR_BAD_HANDLE = &H600b

' KERNEL parameter errors 
Global Const ERR_BAD_HINSTANCE = &H6020
Global Const ERR_BAD_HMODULE = &H6021
Global Const ERR_BAD_GLOBAL_HANDLE = &H6022
Global Const ERR_BAD_LOCAL_HANDLE = &H6023
Global Const ERR_BAD_ATOM = &H6024
Global Const ERR_BAD_HFILE = &H6025

' USER parameter errors 
Global Const ERR_BAD_HWND = &H6040
Global Const ERR_BAD_HMENU = &H6041
Global Const ERR_BAD_HCURSOR = &H6042
Global Const ERR_BAD_HICON = &H6043
Global Const ERR_BAD_HDWP = &H6044
Global Const ERR_BAD_CID = &H6045
Global Const ERR_BAD_HDRVR = &H6046

' GDI parameter errors 
Global Const ERR_BAD_COORDS = &H7060
Global Const ERR_BAD_GDI_OBJECT = &H6061
Global Const ERR_BAD_HDC = &H6062
Global Const ERR_BAD_HPEN = &H6063
Global Const ERR_BAD_HFONT = &H6064
Global Const ERR_BAD_HBRUSH = &H6065
Global Const ERR_BAD_HBITMAP = &H6066
Global Const ERR_BAD_HRGN = &H6067
Global Const ERR_BAD_HPALETTE = &H6068
Global Const ERR_BAD_HMETAFILE = &H6069


' ***** LogError() values *****

' KERNEL errors 
Global Const ERR_GALLOC = &H0001
Global Const ERR_GREALLOC = &H0002
Global Const ERR_GLOCK = &H0003
Global Const ERR_LALLOC = &H0004
Global Const ERR_LREALLOC = &H0005
Global Const ERR_LLOCK = &H0006
Global Const ERR_ALLOCRES = &H0007
Global Const ERR_LOCKRES = &H0008
Global Const ERR_LOADMODULE = &H0009

' USER errors 
Global Const ERR_CREATEDLG = &H0040
Global Const ERR_CREATEDLG2 = &H0041
Global Const ERR_REGISTERCLASS = &H0042
Global Const ERR_DCBUSY = &H0043
Global Const ERR_CREATEWND = &H0044
Global Const ERR_STRUCEXTRA = &H0045
Global Const ERR_LOADSTR = &H0046
Global Const ERR_LOADMENU = &H0047
Global Const ERR_NESTEDBEGINPAINT = &H0048
Global Const ERR_BADINDEX = &H0049
Global Const ERR_CREATEMENU = &H004a

' GDI errors 
Global Const ERR_CREATEDC = &H0080
Global Const ERR_CREATEMETA = &H0081
Global Const ERR_DELOBJSELECTED = &H0082
Global Const ERR_SELBITMAP = &H0083

' Debugging support (DEBUG SYSTEM ONLY) 
Type WINDEBUGINFO
	flags As Integer
	dwOptions As Long
	dwFilter As Long
	achAllocModule As String * 8
	dwAllocBreak As Long
	dwAllocCount As Long
End Type

Declare Function GetWinDebugInfo Lib "Kernel" (lpwdi As WINDEBUGINFO, ByVal flags As Integer) As Integer
Declare Function SetWinDebugInfo Lib "Kernel" (lpwdi As WINDEBUGINFO) As Integer
Declare Sub DebugOutput Lib "Kernel" (flags As Integer, ByVal lpszFmt As String)

' WINDEBUGINFO flags values 
Global Const WDI_OPTIONS = &H0001
Global Const WDI_FILTER = &H0002
Global Const WDI_ALLOCBREAK = &H0004

' dwOptions values 
Global Const DBO_CHECKHEAP = &H0001
Global Const DBO_BUFFERFILL = &H0004
Global Const DBO_DISABLEGPTRAPPING = &H0010
Global Const DBO_CHECKFREE = &H0020
Global Const DBO_SILENT = &H8000
Global Const DBO_TRACEBREAK = &H2000
Global Const DBO_WARNINGBREAK = &H1000
Global Const DBO_NOERRORBREAK = &H0800
Global Const DBO_NOFATALBREAK = &H0400
Global Const DBO_INT3BREAK = &H0100

' DebugOutput flags values 
Global Const DBF_TRACE = &H0000
Global Const DBF_WARNING = &H4000
Global Const DBF_ERROR = &H8000
Global Const DBF_FATAL = &Hc000

' dwFilter values 
Global Const DBF_KERNEL = &H1000
Global Const DBF_KRN_MEMMAN = &H0001
Global Const DBF_KRN_LOADMODULE = &H0002
Global Const DBF_KRN_SEGMENTLOAD = &H0004
Global Const DBF_USER = &H0800
Global Const DBF_GDI = &H0400
Global Const DBF_MMSYSTEM = &H0040
Global Const DBF_PENWIN = &H0020
Global Const DBF_APPLICATION = &H0008
Global Const DBF_DRIVER = &H0010

Global Const EW_REBOOTSYSTEM = &H43

Declare Function ExitWindowsExec Lib "User" (ByVal lpszExe As String, ByVal lpszParams As String) As Integer
Declare Function IsBadReadPtr Lib "Kernel" (ByVal lp As String, ByVal cb As Integer) As Integer
Declare Function IsBadWritePtr Lib "Kernel" (ByVal lp As String, ByVal cb As Integer) As Integer
Declare Function IsBadStringPtr Lib "Kernel" (ByVal lpsz As String, ByVal cchMax As Integer) As Integer
Declare Function IsTask Lib "Kernel" (ByVal htask As Integer) As Integer

Global Const OBM_UPARROWI = 32737
Global Const OBM_DNARROWI = 32736
Global Const OBM_RGARROWI = 32735
Global Const OBM_LFARROWI = 32734

Declare Function lstrcpyn Lib "Kernel" (ByVal lpszString1 As String, ByVal lpszString2 As String, ByVal cChars As Integer) As String
Declare Function IsDBCSLeadByte Lib "Kernel" (ByVal bTestChar As Integer) As Integer

Type SIZE
	cx As Integer
	cy As Integer
End Type

' Drawing bounds accumulation APIs 
Declare Function SetBoundsRect Lib "GDI" (ByVal hdc As Integer, lprcBounds As RECT, ByVal flags As Integer) As Integer
Declare Function GetBoundsRect Lib "GDI" (ByVal hdc As Integer, lprcBounds As RECT, ByVal flags As Integer) As Integer

Global Const DCB_RESET = &H0001
Global Const DCB_ACCUMULATE = &H0002
Global Const DCB_DIRTY = DCB_ACCUMULATE
Global Const DCB_SET = (DCB_RESET Or DCB_ACCUMULATE)
Global Const DCB_ENABLE = &H0004
Global Const DCB_DISABLE = &H0008

Declare Function SetWindowOrgEx Lib "GDI" (ByVal hdc As Integer, ByVal nX As Integer, ByVal nY As Integer, lpPoint As POINTAPI) As Integer
Declare Function GetWindowOrgEx Lib "GDI" (ByVal hdc As Integer, lpPoint As POINTAPI) As Integer
Declare Function SetWindowExtEx Lib "GDI" (ByVal hdc As Integer, ByVal nX As Integer, ByVal nY As Integer, lpSize As SIZE) As Integer
Declare Function GetWindowExtEx Lib "GDI" (ByVal hdc As Integer, lpSize As SIZE) As Integer
Declare Function OffsetWindowOrgEx Lib "GDI" (ByVal hdc As Integer, ByVal nX As Integer, ByVal nY As Integer, lpPoint As POINTAPI) As Integer
Declare Function ScaleWindowExtEx% Lib "GDI" (ByVal hdc%, ByVal nXnum%,  ByVal nXdenom%, ByVal nYnum%, ByVal nYdenom%, lpSize As SIZE)
Declare Function SetViewportExtEx Lib "GDI" (ByVal hdc As Integer, ByVal nX As Integer, ByVal nY As Integer, lpSize As SIZE) As Integer
Declare Function GetViewportExtEx Lib "GDI" (ByVal hdc As Integer, lpSize As SIZE) As Integer
Declare Function SetViewportOrgEx Lib "GDI" (ByVal hdc As Integer, ByVal nX As Integer, ByVal nY As Integer, lpPoint As POINTAPI) As Integer
Declare Function GetViewportOrgEx Lib "GDI" (ByVal hdc As Integer, lpPoint As POINTAPI) As Integer
Declare Function OffsetViewportOrgEx Lib "GDI" (ByVal hdc As Integer, ByVal nX As Integer, ByVal nY As Integer, lpPoint As POINTAPI) As Integer
Declare Function ScaleViewportExtEx% Lib "GDI" (ByVal hdc%, ByVal nXnum%, ByVal nXdenom%, ByVal nYnum%, ByVal nYdenom%, lpSize As SIZE)

Global Const COLOR_INACTIVECAPTIONTEXT = 19
Global Const COLOR_BTNHIGHLIGHT = 20

Declare Function GetBrushOrgEx Lib "GDI" (ByVal hdc As Integer, lpPoint As POINTAPI) As Integer
Declare Function MoveToEx Lib "GDI" (ByVal hdc As Integer, ByVal x As Integer, ByVal y As Integer, lpPoint As POINTAPI) As Integer
Declare Function GetCurrentPositionEx Lib "GDI" (ByVal hdc As Integer, lpPoint As POINTAPI) As Integer
Declare Function GetTextExtentPoint Lib "GDI" (ByVal hdc As Integer, ByVal lpszString As String, ByVal cbString As Integer, lpSize As SIZE) As Integer

Global Const OUT_TT_PRECIS = 4
Global Const OUT_DEVICE_PRECIS = 5
Global Const OUT_RASTER_PRECIS = 6
Global Const OUT_TT_ONLY_PRECIS = 7

Global Const CLIP_LH_ANGLES = &H10
Global Const CLIP_TT_ALWAYS = &H20
Global Const CLIP_EMBEDDED = &H80

Declare Function GetAspectRatioFilterEx Lib "GDI" (ByVal hdc As Integer, lpAspectRatio As SIZE) As Integer

Global Const TMPF_TRUETYPE = &H04

Type PANOSE
	bFamilyType As String * 1
	bSerifStyle As String * 1
	bWeight As String * 1
	bProportion As String * 1
	bContrast As String * 1
	bStrokeVariation As String * 1
	bArmStyle As String * 1
	bLetterform As String * 1
	bMidline As String * 1
	bXHeight As String * 1
End Type

Type OUTLINETEXTMETRIC
	otmSize As Integer
	otmTextMetrics As TEXTMETRIC
	otmFiller As String * 1
	otmPanoseNumber As PANOSE
	otmfsSelection As Integer
	otmfsType As Integer
	otmsCharSlopeRise As Integer
	otmsCharSlopeRun As Integer
	otmItalicAngle As Integer
	otmEMSquare As Integer
	otmAscent As Integer
	otmDescent As Integer
	otmLineGap As Integer
	otmsCapEmHeight As Integer
	otmsXHeight As Integer
	otmrcFontBox As RECT
	otmMacAscent As Integer
	otmMacDescent As Integer
	otmMacLineGap As Integer
	otmusMinimumPPEM As Integer
	otmptSubscriptSize As POINTAPI
	otmptSubscriptOffset As POINTAPI
	otmptSuperscriptSize As POINTAPI
	otmptSuperscriptOffset As POINTAPI
	otmsStrikeoutSize As Integer
	otmsStrikeoutPosition As Integer
	otmsUnderscorePosition As Integer
	otmsUnderscoreSize As Integer
	otmpFamilyName As Long
	otmpFaceName As Long
	otmpStyleName As Long
	otmpFullName As Long
End Type

Declare Function GetOutlineTextMetrics Lib "GDI" (ByVal hdc As Integer, ByVal cbData As Integer, lpotm As OUTLINETEXTMETRIC) As Integer

' Structure passed to FONTENUMPROC 
' NOTE: NEWTEXTMETRIC is the same as TEXTMETRIC plus 4 new fields 
Type NEWTEXTMETRIC
	tmHeight As Integer
	tmAscent As Integer
	tmDescent As Integer
	tmInternalLeading As Integer
	tmExternalLeading As Integer
	tmAveCharWidth As Integer
	tmMaxCharWidth As Integer
	tmWeight As Integer
	tmItalic As String * 1
	tmUnderlined As String * 1
	tmStruckOut As String * 1
	tmFirstChar As String * 1
	tmLastChar As String * 1
	tmDefaultChar As String * 1
	tmBreakChar As String * 1
	tmPitchAndFamily As String * 1
	tmCharSet As String * 1
	tmOverhang As Integer
	tmDigitizedAspectX As Integer
	tmDigitizedAspectY As Integer
	ntmFlags As Long
	ntmSizeEM As Integer
	ntmCellHeight As Integer
	ntmAvgWidth As Integer
End Type

' ntmFlags field flags 
Global Const NTM_REGULAR = &H00000040&
Global Const NTM_BOLD = &H00000020&
Global Const NTM_ITALIC = &H00000001&

Global Const LF_FULLFACESIZE = 64

Global Const TRUETYPE_FONTTYPE = &H0004

Declare Function GetFontData& Lib "GDI" (ByVal hdc%, ByVal dwTable&, ByVal dwOffset&, ByVal lpvBuffer$, ByVal cbData&)
Declare Function CreateScalableFontResource% Lib "GDI" (ByVal fHidden%, ByVal lpszResourceFile$, ByVal lpszFontFile$, ByVal lpszCurrentPath$)

Type GLYPHMETRICS
	gmBlackBoxX As Integer
	gmBlackBoxY As Integer
	gmptGlyphOrigin As POINTAPI
	gmCellIncX As Integer
	gmCellIncY As Integer
End Type

Type FIXED
	fract As Integer
	value As Integer
End Type

Type MAT2
	eM11 As FIXED
	eM12 As FIXED
	eM21 As FIXED
	eM22 As FIXED
End Type

Declare Function GetGlyphOutline& Lib "GDI" (ByVal hdc%, ByVal uChar%, ByVal fuFormat%, lpgm As GLYPHMETRICS, ByVal cbBuffer&, ByVal lpBuffer$, lpmat2 As MAT2)

' GetGlyphOutline constants 
Global Const GGO_METRICS = 0
Global Const GGO_BITMAP = 1
Global Const GGO_NATIVE = 2

Global Const TT_POLYGON_TYPE = 24

Global Const TT_PRIM_LINE = 1
Global Const TT_PRIM_QSPLINE = 2

Type POINTFX
	x As FIXED
	y As FIXED
End Type

Type TTPOLYCURVE
	wType As Integer
	cpfx As Integer
	apfx As POINTFX
End Type

Type TTPOLYGONHEADER
	cb As Long
	dwType As Long
	pfxStart As POINTFX
End Type

Type ABC
	abcA As Integer
	abcB As Integer
	abcC As Integer
End Type

Declare Function GetCharABCWidths Lib "GDI" (ByVal hdc As Integer, ByVal uFirstChar As Integer, ByVal uLastChar As Integer, lpabc As ABC) As Integer

Type KERNINGPAIR
	wFirst As Integer
	wSecond As Integer
	iKernAmount As Integer
End Type

Declare Function GetKerningPairs Lib "GDI" (ByVal hdc As Integer, ByVal cPairs As Integer, lpkrnpair As KERNINGPAIR) As Integer

Type RASTERIZER_STATUS
	nSize As Integer
	wFlags As Integer
	nLanguageID As Integer
End Type

' bits defined in wFlags of RASTERIZER_STATUS 
Global Const TT_AVAILABLE = &H0001
Global Const TT_ENABLED = &H0002

Declare Function GetRasterizerCaps Lib "GDI" (lpraststat As RASTERIZER_STATUS, ByVal cb As Integer) As Integer
Declare Function SetBitmapDimensionEx Lib "GDI" (ByVal hbm As Integer, ByVal nX As Integer, ByVal nY As Integer, lpSize As SIZE) As Integer
Declare Function GetBitmapDimensionEx Lib "GDI" (ByVal hBitmap As Integer, lpDimension As SIZE) As Integer
Declare Function SetMetaFileBitsBetter Lib "GDI" (ByVal hmt As Integer) As Integer

Type DOCINFO
	cbSize As Integer
	lpszDocName As Long
	lpszOutput As Long
End Type

Declare Function StartDoc Lib "GDI" (ByVal hdc As Integer, lpdi As DOCINFO) As Integer
Declare Function StartPage Lib "GDI" (ByVal hdc As Integer) As Integer
Declare Function EndPage Lib "GDI" (ByVal hdc As Integer) As Integer
Declare Function EndDocAPI Lib "GDI" Alias "EndDoc" (ByVal hdc As Integer) As Integer
Declare Function AbortDoc Lib "GDI" (ByVal hdc As Integer) As Integer
Declare Function SpoolFile Lib "GDI" (ByVal lpszPrinter As String, ByVal lpszPort As String, ByVal lpszJob As String, ByVal lpszFile As String) As Integer

Global Const SM_CXDOUBLECLK = 36
Global Const SM_CYDOUBLECLK = 37
Global Const SM_CXICONSPACING = 38
Global Const SM_CYICONSPACING = 39
Global Const SM_MENUDROPALIGNMENT = 40
Global Const SM_PENWINDOWS = 41
Global Const SM_DBCSENABLED = 42

Declare Function SystemParametersInfo Lib "User" (ByVal uAction As Integer, ByVal uParam As Integer, lpvParam As Any, ByVal fuWinIni As Integer) As Integer

Global Const SPI_GETBEEP = 1
Global Const SPI_SETBEEP = 2
Global Const SPI_GETMOUSE = 3
Global Const SPI_SETMOUSE = 4
Global Const SPI_GETBORDER = 5
Global Const SPI_SETBORDER = 6
Global Const SPI_GETKEYBOARDSPEED = 10
Global Const SPI_SETKEYBOARDSPEED = 11
Global Const SPI_LANGDRIVER = 12
Global Const SPI_ICONHORIZONTALSPACING = 13
Global Const SPI_GETSCREENSAVETIMEOUT = 14
Global Const SPI_SETSCREENSAVETIMEOUT = 15
Global Const SPI_GETSCREENSAVEACTIVE = 16
Global Const SPI_SETSCREENSAVEACTIVE = 17
Global Const SPI_GETGRIDGRANULARITY = 18
Global Const SPI_SETGRIDGRANULARITY = 19
Global Const SPI_SETDESKWALLPAPER = 20
Global Const SPI_SETDESKPATTERN = 21
Global Const SPI_GETKEYBOARDDELAY = 22
Global Const SPI_SETKEYBOARDDELAY = 23
Global Const SPI_ICONVERTICALSPACING = 24
Global Const SPI_GETICONTITLEWRAP = 25
Global Const SPI_SETICONTITLEWRAP = 26
Global Const SPI_GETMENUDROPALIGNMENT = 27
Global Const SPI_SETMENUDROPALIGNMENT = 28
Global Const SPI_SETDOUBLECLKWIDTH = 29
Global Const SPI_SETDOUBLECLKHEIGHT = 30
Global Const SPI_GETICONTITLELOGFONT = 31
Global Const SPI_SETDOUBLECLICKTIME = 32
Global Const SPI_SETMOUSEBUTTONSWAP = 33
Global Const SPI_SETICONTITLELOGFONT = 34
Global Const SPI_GETFASTTASKSWITCH = 35
Global Const SPI_SETFASTTASKSWITCH = 36

' SystemParametersInfo flags 
Global Const SPIF_UPDATEINIFILE = &H0001
Global Const SPIF_SENDWININICHANGE = &H0002

Declare Function GetMessageExtraInfo Lib "User" () As Long
Declare Function GetQueueStatus Lib "User" (ByVal fuFlags As Integer) As Long

' GetQueueStatus flags 
Global Const QS_KEY = &H0001
Global Const QS_MOUSEMOVE = &H0002
Global Const QS_MOUSEBUTTON = &H0004
Global Const QS_MOUSE = (QS_MOUSEMOVE Or QS_MOUSEBUTTON)
Global Const QS_POSTMESSAGE = &H0008
Global Const QS_TIMER = &H0010
Global Const QS_PAINT = &H0020
Global Const QS_SENDMESSAGE = &H0040

Global Const QS_ALLINPUT = &H007f


' ***** Power management *****

Global Const WM_POWER = &H0048

' wParam for WM_POWER window message and DRV_POWER driver notification 
Global Const PWR_OK = 1
Global Const PWR_FAIL = -1
Global Const PWR_SUSPENDREQUEST = 1
Global Const PWR_SUSPENDRESUME = 2
Global Const PWR_CRITICALRESUME = 3

Global Const GCW_ATOM = -32

Global Const WS_EX_TOPMOST = &H00000008&
Global Const WS_EX_ACCEPTFILES = &H00000010&
Global Const WS_EX_TRANSPARENT = &H00000020&

Type WINDOWPLACEMENT
	length As Integer
	flags As Integer
	showCmd As Integer
	ptMinPosition As POINTAPI
	ptMaxPosition As POINTAPI
	rcNormalPosition As RECT
End Type

Global Const WPF_SETMINPOSITION = &H0001
Global Const WPF_RESTORETOMAXIMIZED = &H0002

Declare Function GetWindowPlacement Lib "User" (ByVal hwnd As Integer, lpwndpl As WINDOWPLACEMENT) As Integer
Declare Function SetWindowPlacement Lib "User" (ByVal hwnd As Integer, lpwndpl As WINDOWPLACEMENT) As Integer

Global Const WM_WINDOWPOSCHANGING = &H0046
Global Const WM_WINDOWPOSCHANGED = &H0047

' WM_WINDOWPOSCHANGING/CHANGED struct pointed to by lParam 
Type WINDOWPOS
	hwnd As Integer
	hwndInsertAfter As Integer
	x As Integer
	y As Integer
	cx As Integer
	cy As Integer
	flags As Integer
End Type

Declare Sub MapWindowPoints Lib "User" (ByVal hwndFrom As Integer, ByVal hwndTo As Integer, lppt As POINTAPI, ByVal cPoints As Integer)
Declare Function GetDCEx Lib "User" (ByVal hwnd As Integer, ByVal hrgnclip As Integer, ByVal fdwOptions As Long) As Integer

Global Const DCX_WINDOW = &H00000001&
Global Const DCX_CACHE = &H00000002&
Global Const DCX_CLIPCHILDREN = &H00000008&
Global Const DCX_CLIPSIBLINGS = &H00000010&
Global Const DCX_PARENTCLIP = &H00000020&
Global Const DCX_EXCLUDERGN = &H00000040&
Global Const DCX_INTERSECTRGN = &H00000080&
Global Const DCX_LOCKWINDOWUPDATE = &H00000400&
Global Const DCX_USESTYLE = &H00010000&

Declare Function LockWindowUpdate Lib "User" (ByVal hwndLock As Integer) As Integer
Declare Function RedrawWindow Lib "User" (ByVal hwnd As Integer, lprcUpdate As RECT, ByVal hrgnUpdate As Integer, ByVal fuRedraw As Integer) As Integer

Global Const RDW_INVALIDATE = &H0001
Global Const RDW_INTERNALPAINT = &H0002
Global Const RDW_ERASE = &H0004
Global Const RDW_VALIDATE = &H0008
Global Const RDW_NOINTERNALPAINT = &H0010
Global Const RDW_NOERASE = &H0020
Global Const RDW_NOCHILDREN = &H0040
Global Const RDW_ALLCHILDREN = &H0080
Global Const RDW_UPDATENOW = &H0100
Global Const RDW_ERASENOW = &H0200
Global Const RDW_FRAME = &H0400
Global Const RDW_NOFRAME = &H0800

Declare Function ScrollWindowEx% Lib "User" (ByVal hwnd%, ByVal dx%, ByVal dy%, lprcScroll As RECT, lprcClip As RECT, ByVal hrgnUpdate%, lprcUpdate As RECT, ByVal fuScroll%)

Global Const SW_SCROLLCHILDREN = &H0001
Global Const SW_INVALIDATE = &H0002
Global Const SW_ERASE = &H0004

' WM_NCCALCSIZE return flags 
Global Const WVR_ALIGNTOP = &H0010
Global Const WVR_ALIGNLEFT = &H0020
Global Const WVR_ALIGNBOTTOM = &H0040
Global Const WVR_ALIGNRIGHT = &H0080
Global Const WVR_HREDRAW = &H0100
Global Const WVR_VREDRAW = &H0200
Global Const WVR_REDRAW = (WVR_HREDRAW Or WVR_VREDRAW)
Global Const WVR_VALIDRECTS = &H0400

' WM_NCCALCSIZE parameter structure 
Type NCCALCSIZE_PARAMS
	rgrc As Long
	lppos As Long
End Type

Global Const MA_NOACTIVATEANDEAT =  4

Declare Function IsMenu Lib "User" (ByVal hmenu As Integer) As Integer

Global Const TPM_RIGHTBUTTON = &H0002
Global Const TPM_LEFTALIGN = &H0000
Global Const TPM_CENTERALIGN = &H0004
Global Const TPM_RIGHTALIGN = &H0008

Declare Function GetOpenClipboardWindow Lib "User" () As Integer
Declare Function CopyCursor Lib "User" (ByVal hinst As Integer, ByVal hcur As Integer) As Integer
Declare Function GetCursor Lib "User" () As Integer
Declare Sub GetClipCursor Lib "User" (lprc As RECT)
Declare Function CopyIcon Lib "User" (ByVal hinst As Integer, ByVal hicon As Integer) As Integer

Global Const MDIS_ALLCHILDSTYLES = &H0001

' wParam values for WM_MDITILE and WM_MDICASCADE messages. 
Global Const MDITILE_VERTICAL = &H0000
Global Const MDITILE_HORIZONTAL = &H0001
Global Const MDITILE_SKIPDISABLED = &H0002

' Static Control Mesages 
Global Const STM_SETICON = (WM_USER+0)
Global Const STM_GETICON = (WM_USER+1)

Global Const ES_READONLY = &H00000800&
Global Const ES_WANTRETURN = &H00001000&

Global Const EM_GETFIRSTVISIBLELINE = (WM_USER+30)
Global Const EM_SETREADONLY = (WM_USER+31)
Global Const EM_SETWORDBREAKPROC = (WM_USER+32)
Global Const EM_GETWORDBREAKPROC = (WM_USER+33)
Global Const EM_GETPASSWORDCHAR = (WM_USER+34)

' EDITWORDBREAKPROC code values 
Global Const WB_LEFT = 0
Global Const WB_RIGHT = 1
Global Const WB_ISDELIMITER = 2

Global Const LBS_DISABLENOSCROLL = &H1000&

Global Const LB_SETITEMHEIGHT = (WM_USER+33)
Global Const LB_GETITEMHEIGHT = (WM_USER+34)
Global Const LB_FINDSTRINGEXACT = (WM_USER+35)

Declare Function DlgDirSelectEx% Lib "User" (ByVal hwndDlg%, ByVal lpszPath$, ByVal cbPath%, ByVal idListBox%)
Declare Function DlgDirSelectComboBoxEx% Lib "User" (ByVal hwndDlg%, ByVal lpszPath$, ByVal cbPath%, ByVal idComboBox%)

Global Const CBS_DISABLENOSCROLL = &H0800&

Global Const CB_SETITEMHEIGHT = (WM_USER+19)
Global Const CB_GETITEMHEIGHT = (WM_USER+20)
Global Const CB_SETEXTENDEDUI = (WM_USER+21)
Global Const CB_GETEXTENDEDUI = (WM_USER+22)
Global Const CB_GETDROPPEDSTATE = (WM_USER+23)
Global Const CB_FINDSTRINGEXACT = (WM_USER+24)

Global Const CBN_CLOSEUP = 8
Global Const CBN_SELENDOK = 9
Global Const CBN_SELENDCANCEL = 10

Declare Function UnhookWindowsHookEx Lib "User" (ByVal hHook As Integer) As Integer
Declare Function CallNextHookEx Lib "User" (ByVal hHook As Integer, ByVal ncode As Integer, ByVal wParam As Integer, lParam As Any) As Long

' HCBT_CREATEWND parameters pointed to by lParam 
Type CBT_CREATEWND
	lpcs As Long
	hwndInsertAfter As Integer
End Type

' HCBT_ACTIVATE structure pointed to by lParam 
Type CBTACTIVATESTRUCT
	fMouse As Integer
	hWndActive As Integer
End Type


Global Const WH_HARDWARE = 8

Type HARDWAREHOOKSTRUCT
	hWnd As Integer
	wMessage As Integer
	wParam As Integer
	lParam As Long
End Type

' SetWindowsHook() Shell hook code 
Global Const WH_SHELL = 10

Global Const HSHELL_WINDOWCREATED = 1
Global Const HSHELL_WINDOWDESTROYED = 2
Global Const HSHELL_ACTIVATESHELLWINDOW = 3


' SetWindowsHook debug hook support 
Global Const WH_DEBUG = 9

Type DEBUGHOOKINFO
	hModuleHook As Integer
	reserved As Long
	lParam As Long
	wParam As Integer
	code As Integer
End Type

Declare Function QuerySendMessage Lib "User" (ByVal hreserved1 As Integer, ByVal hreserved2 As Integer, ByVal hreserved3 As Integer, ByVal lpMessage As String) As Integer
Declare Function LockInput Lib "User" (ByVal hReserved As Integer, ByVal hwndInput As Integer, ByVal fLock As Integer) As Integer
Declare Function GetSystemDebugState Lib "User" () As Long

' Flags returned by GetSystemDebugState.
Global Const SDS_MENU = &H0001
Global Const SDS_SYSMODAL = &H0002
Global Const SDS_NOTASKQUEUE = &H0004
Global Const SDS_DIALOG = &H0008
Global Const SDS_TASKLOCKED = &H0010

' new escape functions 
Global Const GETMAXLPT = 8
Global Const GETMAXCOM = 9
Global Const GETBASEIRQ = 10

' Comm Baud Rate indices 
Global Const CBR_110 = &HFF10
Global Const CBR_300 = &HFF11
Global Const CBR_600 = &HFF12
Global Const CBR_1200 = &HFF13
Global Const CBR_2400 = &HFF14
Global Const CBR_4800 = &HFF15
Global Const CBR_9600 = &HFF16
Global Const CBR_14400 = &HFF17
Global Const CBR_19200 = &HFF18
Global Const CBR_38400 = &HFF1B
Global Const CBR_56000 = &HFF1F
Global Const CBR_128000 = &HFF23
Global Const CBR_256000 = &HFF27

' notifications passed in low word of lParam on WM_COMMNOTIFY messages 
Global Const CN_RECEIVE = &H0001
Global Const CN_TRANSMIT = &H0002
Global Const CN_EVENT = &H0004

Declare Function EnableCommNotification Lib "User" (ByVal idComDev As Integer, ByVal hwnd As Integer, ByVal cbWriteNotify As Integer, ByVal OutQueue As Integer) As Integer

Global Const WM_COMMNOTIFY = &H0044

' Driver messages 
Global Const DRV_LOAD = &H0001
Global Const DRV_ENABLE = &H0002
Global Const DRV_OPEN = &H0003
Global Const DRV_CLOSE = &H0004
Global Const DRV_DISABLE = &H0005
Global Const DRV_FREE = &H0006
Global Const DRV_CONFIGURE = &H0007
Global Const DRV_QUERYCONFIGURE = &H0008
Global Const DRV_INSTALL = &H0009
Global Const DRV_REMOVE = &H000A
Global Const DRV_EXITSESSION = &H000B
Global Const DRV_EXITAPPLICATION = &H000C
Global Const DRV_POWER = &H000F
Global Const DRV_RESERVED = &H0800
Global Const DRV_USER = &H4000

' LPARAM of DRV_CONFIGURE message 
Type DRVCONFIGINFO
	dwDCISize As Long
	lpszDCISectionName As Long
	lpszDCIAliasName As Long
End Type

' Supported return values for DRV_CONFIGURE message 
Global Const DRVCNF_CANCEL = &H0000
Global Const DRVCNF_OK = &H0001
Global Const DRVCNF_RESTART = &H0002

' Supported lParam1 of DRV_EXITAPPLICATION notification 
Global Const DRVEA_NORMALEXIT = &H0001
Global Const DRVEA_ABNORMALEXIT = &H0002

Declare Function DefDriverProc Lib "User" (ByVal dwDriverIdentifier As Long, ByVal hdrvr As Integer, ByVal umsg As Integer, lParam1 As Any, lParam2 As Any) As Long
Declare Function OpenDriver Lib "User" (ByVal lpDriverName As String, ByVal lpSectionName As String, lParam As Any) As Integer
Declare Function CloseDriver Lib "User" (ByVal hdrvr As Integer, lParam1 As Any, lParam2 As Any) As Long
Declare Function SendDriverMessage Lib "User" (ByVal hdrvr As Integer, ByVal msg As Integer, lParam1 As Any, lParam2 As Any) As Long
Declare Function GetDriverModuleHandle Lib "User" (ByVal hdrvr As Integer) As Integer
Declare Function GetNextDriver Lib "User" (ByVal hdrvr As Integer, ByVal fdwFlag As Long) As Integer

' GetNextDriver flags 
Global Const GND_FIRSTINSTANCEONLY = &H00000001

Global Const GND_FORWARD = &H00000000
Global Const GND_REVERSE = &H00000002

Type DRIVERINFOSTRUCT
	length As Integer
	hDriver As Integer
	hModule As Integer
	szAliasName As String * 128
End Type

Declare Function GetDriverInfo Lib "User" (ByVal hdrvr As Integer, lpdis As DRIVERINFOSTRUCT) As Integer


' ***** LZEXPAND error return codes *****

Global Const LZERROR_BADINHANDLE = (-1)  '  invalid input handle 
Global Const LZERROR_BADOUTHANDLE = (-2) '  invalid output handle 
Global Const LZERROR_READ = (-3)         '  corrupt compressed file format 
Global Const LZERROR_WRITE = (-4)        '  out of space for output file 
Global Const LZERROR_GLOBALLOC = (-5)    '  insufficient memory for LZFile struct 
Global Const LZERROR_GLOBLOCK = (-6)     '  bad global handle 
Global Const LZERROR_BADVALUE = (-7)     '  input parameter out of range 
Global Const LZERROR_UNKNOWNALG = (-8)   '  compression algorithm not recognized 

Declare Function LZStart Lib "LZexpand.dll" () As Integer
Declare Sub LZDone Lib "LZexpand.dll" ()
Declare Function CopyLZFile Lib "LZexpand.dll" (ByVal hfSource As Integer, ByVal hfDest As Integer) As Long
Declare Function LZCopy Lib "LZexpand.dll" (ByVal hfSource As Integer, ByVal hfDest As Integer) As Long
Declare Function LZInit Lib "LZexpand.dll" (ByVal hfSrc As Integer) As Integer
Declare Function GetExpandedName Lib "LZexpand.dll" (ByVal lpszSource As String, ByVal lpszBuffer As String) As Integer
Declare Function LZOpenFile Lib "LZexpand.dll" (ByVal lpszFile As String, lpOf As OFSTRUCT, ByVal style As Integer) As Integer
Declare Function LZSeek Lib "LZexpand.dll" (ByVal hfFile As Integer, ByVal lOffset As Long, ByVal nOrigin As Integer) As Long
Declare Function LZRead Lib "LZexpand.dll" (ByVal hfFile As Integer, ByVal lpvBuf As String, ByVal cb As Integer) As Integer
Declare Sub LZClose Lib "LZexpand.dll" (ByVal hfFile As Integer)


' ***** Windows Network support *****

Global Const WN_SUCCESS = &H0000
Global Const WN_NOT_SUPPORTED = &H001
Global Const WN_NET_ERROR = &H0002
Global Const WN_MORE_DATA = &H0003
Global Const WN_BAD_POINTER = &H0004
Global Const WN_BAD_VALUE = &H0005
Global Const WN_BAD_PASSWORD = &H0006
Global Const WN_ACCESS_DENIED = &H0007
Global Const WN_FUNCTION_BUSY = &H0008
Global Const WN_WINDOWS_ERROR = &H0009
Global Const WN_BAD_USER = &H000A
Global Const WN_OUT_OF_MEMORY = &H000B
Global Const WN_CANCEL = &H000C
Global Const WN_CONTINUE = &H000D

Global Const WN_NOT_CONNECTED = &H0030
Global Const WN_OPEN_FILES = &H0031
Global Const WN_BAD_NETNAME = &H0032
Global Const WN_BAD_LOCALNAME = &H0033
Global Const WN_ALREADY_CONNECTED = &H0034
Global Const WN_DEVICE_ERROR = &H0035
Global Const WN_CONNECTION_CLOSED = &H0036

Declare Function WNetAddConnection Lib "User" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Integer
Declare Function WNetCancelConnection Lib "User" (ByVal lpszName As String, ByVal bForce As Integer) As Integer
Declare Function WNetGetConnection Lib "User" (ByVal lpszLocalName As String, ByVal lpszRemoteName As String, cbRemoteName As Integer) As Integer
