Private Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Const RGN_AND = 1
Private Const RGN_COPY = 5
Private Const RGN_DIFF = 4
Private Const RGN_OR = 2
Private Const RGN_XOR = 3
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
' API for saving and loading a region:
Private Declare Function GetRegionData Lib "gdi32" (ByVal hRgn As Long, ByVal dwCount As Long, lpRgnData As Any) As Long
Private Declare Function ExtCreateRegion Lib "gdi32" (lpXform As Any, ByVal nCount As Long, lpRgnData As Any) As Long
' API for getting data from an external library module:
Private Declare Function LoadLibraryEx Lib "kernel32" Alias "LoadLibraryExA" (ByVal lpLibFileName As String, ByVal hFile As Long, ByVal dwFlags As Long) As Long
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
Private Declare Function LoadResource Lib "kernel32" (ByVal hInstance As Long, ByVal hResInfo As Long) As Long
Private Declare Function LockResource Lib "kernel32" (ByVal hResData As Long) As Long
Private Declare Function FindResource Lib "kernel32" Alias "FindResourceA" (ByVal hInstance As Long, lpName As Any, lpType As Any) As Long
Private Declare Function SizeofResource Lib "kernel32" (ByVal hInstance As Long, ByVal hResInfo As Long) As Long
Private Declare Function FreeResource Lib "kernel32" (ByVal hResData As Long) As Long
Private Const LOAD_LIBRARY_AS_DATAFILE = &H2&
Private Const RT_RCDATA = 10&
' API for reading cDIBSection bits:
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
lpvDest As Any, lpvSource As Any, ByVal cbCopy As Long)
Private Type SAFEARRAYBOUND
cElements As Long
lLbound As Long
End Type
Private Type SAFEARRAY2D
cDims As Integer
fFeatures As Integer
cbElements As Long
cLocks As Long
pvData As Long
Bounds(0 To 1) As SAFEARRAYBOUND
End Type
Private Declare Function VarPtrArray Lib "msvbvm60.dll" Alias "VarPtr" (Ptr() As Any) As Long
' Implementation:
Private m_hRgn As Long
Private m_hWnd() As Long
Private m_iCount As Long
Public Property Get Applied(ByVal hwnd As Long) As Boolean
Applied = Not (plIndex(hwnd) = 0)
End Property
Public Property Let Applied(ByVal hwnd As Long, ByVal bState As Boolean)
Dim i As Long
Dim lIndex As Long
lIndex = plIndex(hwnd)
If bState Then
If (lIndex = 0) Then
' Apply to window:
m_iCount = m_iCount + 1
ReDim Preserve m_hWnd(1 To m_iCount) As Long
m_hWnd(m_iCount) = hwnd
SetWindowRgn m_hWnd(m_iCount), m_hRgn, True
Else
' already applied, reset apply state jic
SetWindowRgn m_hWnd(m_iCount), m_hRgn, True
End If
Else
If (lIndex = 0) Then
' Not applied, reset state jic
SetWindowRgn hwnd, 0, True
Else
' Applied, reset:
SetWindowRgn hwnd, 0, True
If m_iCount > 1 Then
For i = lIndex To m_iCount - 1
m_hWnd(i) = m_hWnd(i + 1)
Next i
m_iCount = m_iCount - 1
ReDim Preserve m_hWnd(1 To m_iCount) As Long
Else
m_iCount = 0
Erase m_hWnd
End If
End If
End If
End Property
Private Property Get plIndex(ByVal hwnd As Long) As Long
Dim i As Long
Dim lIndex As Long
For i = 1 To m_iCount
If hwnd = m_hWnd(i) Then
plIndex = i
Exit For
End If
Next i
End Property
Public Property Get AppliedToCount() As Long
AppliedToCount = m_iCount
End Property
Public Property Get hWndForIndex(ByVal lIndex As Long) As Long