Attribute VB_Name = "WIN32API"
'/* Ternary raster operations */
Global Const rooll_SRCCOPY = &HCC0020
'Global Const SRCPAINT = &HEE0086
'Global Const SRCAND = &H8800C6
'Global Const MERGEPAINT = &HBB0226
'Global Const SRCERASE = &H440328
'Global Const SRCINVERT = &H660046
'Global Const NOTSRCCOPY = &H330008
'Global Const NOTSRCERASE = &H1100A6
'Global Const MERGECOPY = &HC000CA
'Global Const PATCOPY = &HF00021
'Global Const PATPAINT = &HFB0A09
'Global Const PATINVERT = &H5A0049
'Global Const DSTINVERT = &H550009
'Global Const BLACKNESS = &H42
'Global Const WHITENESS = &HFF0062
'

' SetWindowPos Flags
Global Const SWP_NOSIZE = &H1
Global Const SWP_NOMOVE = &H2
Global Const SWP_NOZORDER = &H4
Global Const SWP_NOREDRAW = &H8
Global Const SWP_NOACTIVATE = &H10
Global Const SWP_DRAWFRAME = &H20
Global Const SWP_SHOWWINDOW = &H40
Global Const SWP_HIDEWINDOW = &H80
Global Const SWP_NOCOPYBITS = &H100
Global Const SWP_NOREPOSITION = &H200

' SetWindowPos() hwndInsertAfter values
Global Const HWND_TOP = 0
Global Const HWND_BOTTOM = 1
Global Const HWND_TOPMOST = -1
Global Const HWND_NOTOPMOST = -2

Global Const WM_KEYUP = &H101
Global Const WM_LBUTTONDOWN = &H201

' GetSystemMetrics() codes
Global Const SM_CYCAPTION = 4
Global Const SM_CXBORDER = 5
Global Const SM_CYBORDER = 6
Global Const SM_CXDLGFRAME = 7
Global Const SM_CYDLGFRAME = 8
Global Const SM_CXFRAME = 32
Global Const SM_CYFRAME = 33
Global Const SM_CYCURSOR = 14

'''/* Virtual key codes */
Global Const VK_LBUTTON = &H1
Global Const VK_RBUTTON = &H2

'' OpenFile() Flags
'Global Const OF_EXIST = &H4000
'
''''''''''''''''''''''''''''''''''''''
' OpenFile() Structure
'Type OFSTRUCT
'   cBytes As String * 1
'   fFixedDisk As String * 1
'   nErrCode As Integer
'   reserved As String * 4
'   szPathName As String * 128
'End Type

' OpenFile() Flags
Public Const OF_READ = &H0
Public Const OF_WRITE = &H1
Public Const OF_READWRITE = &H2
Public Const OF_SHARE_COMPAT = &H0
Public Const OF_SHARE_EXCLUSIVE = &H10
Public Const OF_SHARE_DENY_WRITE = &H20
Public Const OF_SHARE_DENY_READ = &H30
Public Const OF_SHARE_DENY_NONE = &H40
Public Const OF_PARSE = &H100
Public Const OF_DELETE = &H200
Public Const OF_VERIFY = &H400
Public Const OF_CANCEL = &H800
Public Const OF_CREATE = &H1000
Public Const OF_PROMPT = &H2000
Public Const OF_EXIST = &H4000
Public Const OF_REOPEN = &H8000

Public Const OFS_MAXPATHNAME = 128

' OpenFile() Structure
Type OFSTRUCT
        cBytes As Byte
        fFixedDisk As Byte
        nErrCode As Integer
        Reserved1 As Integer
        Reserved2 As Integer
        szPathName(OFS_MAXPATHNAME) As Byte
End Type
Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long
''Declare Function OpenFile Lib "Kernel" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Integer) As Integer
'Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long

'Type POINTAPI
'   x As Integer
'   y As Integer
'End Type
Type POINTAPI
        X As Long
        y As Long
End Type

''''''''''''''''''''''''''''''''''''''
'Declare Sub ClientToScreen Lib "User" (ByVal hWnd As Integer, lpPoint As POINTAPI)
Declare Function ClientToScreen Lib "User32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
'Declare Sub ScreenToClient Lib "User" (ByVal hwnd As Integer, lpPoint As POINTAPI)
Declare Function ScreenToClient Lib "User32" (ByVal hWnd As Long, lpPoint As POINTAPI) As Long
'Declare Function SetParent Lib "User" (ByVal hWndChild As Integer, ByVal hWndNewParent As Integer) As Integer
Declare Function SetParent Lib "User32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Declare Function GetParent Lib "User32" (ByVal hWndChild As Long) As Long

'Declare Function StretchBlt% Lib "GDI" (ByVal hdc%, ByVal x%, ByVal y%, ByVal nWidth%, ByVal nHeight%, ByVal hSrcDC%, ByVal xSrc%, ByVal ySrc%, ByVal nSrcWidth%, ByVal nSrcHeight%, ByVal dwRop&)
Declare Function StretchBlt Lib "gdi32" (ByVal hdc 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 nSrcWidth As Long, ByVal nSrcHeight As Long, ByVal dwRop As Long) As Long
'Declare Function SetCapture Lib "User" (ByVal hwnd As Integer) As Integer
Declare Function SetCapture Lib "User32" (ByVal hWnd As Long) As Long
Declare Function GetCapture Lib "User32" () As Long
'Declare Sub ReleaseCapture Lib "User" ()
Declare Function ReleaseCapture Lib "User32" () As Long
'Declare Sub SetWindowPos Lib "User" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer)
Declare Function SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
'Declare Sub GetCursorPos Lib "User" (lpPoint As POINTAPI)
Declare Function GetCursorPos Lib "User32" (lpPoint As POINTAPI) As Long
'Declare Function WindowFromPoint Lib "User" (ByVal ptScreen As Any) As Integer
Declare Function WindowFromPoint Lib "User32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
'Declare Function SendMessage Lib "User" (ByVal hWnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Integer
Declare Function SendMessage Lib "User32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
'Declare Function PostMessage Lib "User" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, lParam As Any) As Integer
Declare Function PostMessage Lib "User32" Alias "PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'Declare Function GetTickCount Lib "User" () As Long
Declare Function GetTickCount Lib "kernel32" () As Long
'Declare Function GetSystemMetrics Lib "User" (ByVal nIndex As Integer) As Integer
Declare Function GetSystemMetrics Lib "User32" (ByVal nIndex As Long) As Long
'---Declare Function SetFocusAPI Lib "User" Alias "SetFocus" (ByVal hwnd As Integer) As Integer
'---Declare Function GetFocus Lib "User" () As Integer
'Declare Function GetKeyState Lib "User" (ByVal nVirtKey As Integer) As Integer
Declare Function GetFocus Lib "User32" () As Long
Declare Function GetKeyState Lib "User32" (ByVal nVirtKey As Long) As Integer

'Declare Function GetPrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal ApKeyName As String, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

'Declare Function WritePrivateProfileString Lib "Kernel" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As String, ByVal lplFileName As String) As Integer
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Public Const SW_HIDE = 0
Declare Function ShowWindow Lib "User32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

Declare Function GetKeyboardState Lib "User32" (pbKeyState As Any) As Long


'to find path of systems dir on user machine
Declare Function GetWindowsDirectory Lib "kernel32" Alias "GetWindowsDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Declare Function GetSystemDirectory Lib "kernel32" Alias "GetSystemDirectoryA" (ByVal lpBuffer As String, ByVal nSize As Long) As Long
Function GetWindowsPath()

'getting windows folder
    sBuf = String(255, 0)
    cSize = 255

    retval = GetWindowsDirectory(sBuf, cSize)

    sBuf = Left(sBuf, retval)

End Function

Function GetSystemPath()
    
'getting system folder
    sBuf = String(255, 0)
    cSize = 255

    retval = GetSystemDirectory(sBuf, cSize)

    sBuf = Left(sBuf, retval)

End Function


Function GetOFSTRUCT_FileName(lpReOpenBuff As OFSTRUCT) As String
Dim s$
Dim i%
   s$ = s$: i% = 0
   Do While True
      If lpReOpenBuff.szPathName(i%) = 0 Then Exit Do
      s$ = s$ + Chr(lpReOpenBuff.szPathName(i%))
      i% = i% + 1
   Loop
   GetOFSTRUCT_FileName = s$
End Function

Function CmnWindowFromPoint(ByVal X&, ByVal y&) As Long
   CmnWindowFromPoint = WindowFromPoint(X&, y&)
End Function


