⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apiregion.cls

📁 几个不错的VB例子
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "ApiRegion"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Option Explicit

' ##MODULE_DESCRIPTION This class provides the properties and methods _
for manipulating regions.

' ##MODULE_DESCRIPTION A region is a bounded shape that can be as simple _
or as complex as you like.  More complex regions are typically made by _
combining a number of simple (rectangular, rounded rectangular, elliptic or polygonal) _
regions using boolean operators.

'\\ Offset this region
Private Declare Function OffsetRgn Lib "gdi32" (ByVal hRgn As Long, ByVal x As Long, ByVal y As Long) As Long


'\\ Getting more details about the region...
Private Declare Function GetRegionData Lib "gdi32" (ByVal hRgn As Long, ByVal dwCount As Long, lpRgnData As RGNDATA) As Long
Private Declare Function GetRegionDataLong Lib "gdi32" Alias "GetRegionData" (ByVal hRgn As Long, ByVal dwCount As Long, lpRgnData As Long) As Long

'\\ Freeing the object
Private Declare Function DeleteObjectApi Lib "gdi32" Alias "DeleteObject" (ByVal hObject As Long) As Long


Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Private Type RGNDATAHEADER
    dwSize As Long
    iType As Long
    nCount As Long
    nRgnSize As Long
    rcBound As RECT
End Type

Private Type RGNDATA
    rdh As RGNDATAHEADER
    buffer() As Byte
End Type

'\\ Member variables
Private mhRgn As Long
Private mRgnData As RGNDATA

Public Property Let hRgn(ByVal newHRgn As Long)

If newHRgn <> mhRgn Then
    mhRgn = newHRgn
End If

End Property

Public Property Get hRgn() As Long

    hRgn = mhRgn
    
End Property

Public Sub OffsetRegion(ByVal dX As Long, ByVal dY As Long)

Dim lret As Long

lret = OffsetRgn(mhRgn, dX, dY)
If Err.LastDllError Then
    ReportError Err.LastDllError, "ApiRegion:OffsetRegion", GetLastSystemError
End If

End Sub

Private Sub RefreshRegionData()

Dim lret As Long
Dim lSize As Long
Dim buffer() As Byte

lret = GetRegionDataLong(mhRgn, lSize, ByVal 0&)
If Err.LastDllError Then
    ReportError Err.LastDllError, "ApiRegion:GetData", GetLastSystemError
Else
    '\\ Lret is the size of the buffer needed for the region
    ReDim mRgnData.buffer(lret) As Byte
    lret = GetRegionData(mhRgn, lret, mRgnData)
    If Err.LastDllError Then
        ReportError Err.LastDllError, "ApiRegion:GetData", GetLastSystemError
    End If
End If


End Sub


Private Sub Class_Terminate()

Call DeleteObjectApi(mhRgn)
If Err.LastDllError Then
    ReportError Err.LastDllError, "ApiRegion:Terminate", GetLastSystemError
End If

End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -