Private Declare Function CreateRoundRectRgn Lib "gdi32" _
(ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, _
ByVal y2 As Long, ByVal x3 As Long, ByVal y3 As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, _
ByVal hRgn As Long, ByVal bRedraw As Long) As Long
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 CreateEllipticRgn Lib "gdi32" (ByVal x1 As Long, _
ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As Long
Private Declare Function DeleteObject Lib "gdi32" _
(ByVal hObject 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 Declare Function CreatePolygonRgn Lib "gdi32" (lpPoint As POINTAPI, _
ByVal nCount As Long, ByVal nPolyFillMode As Long) As Long
Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function PathToRegion Lib "gdi32" (ByVal hdc As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Const RGN_AND = 1
Private Const RGN_OR = 2
Private Const RGN_XOR = 3
Private Const RGN_DIFF = 4
Private Const RGN_COPY = 5
Dim r As Long
' Создаем круглый регион
r = CreateEllipticRgn(10, 10, 100, 100)
' Привязываем регион к форме
SetWindowRgn hwnd, r, True
' Освобождаем ресурсы
DeleteObject r
Dim p(4) As POINTAPI
p(0).x = 10
p(0).y = 10
p(1).x = 100
p(1).y = 10
p(2).x = 150
p(2).y = 100
p(3).x = 150
p(3).y = 200
p(4).x = 10
p(4).y = 10
r = CreatePolygonRgn(p(0), 5, 1)
SetWindowRgn hwnd, r, True
' Освобождаем ресурсы
DeleteObject r
Dim r as Long
BeginPath hdc
' Здесь мы может что-либо нарисовать с помощью следующих API функций
' ExtTextOut
' LineTo
' MoveToEx
' PolyBezier
' PolyBezierTo
' Polygon
' Polyline
' PolylineTo
' PolyPolygon
' PolyPolyline
' TextOut
EndPath hdc
' Создаем регион из нарисованного
r = PathToRegion(hdc)
Dim r As Long
Font.Name = "Times New Roman"
Font.Bold = True
Font.Size = 72
BeginPath hdc
Print "text"
EndPath hdc
r = PathToRegion(hdc)
SetWindowRgn hWnd, r, True
' Освобождаем ресурсы
DeleteObject r
Private Sub Form_Load()
Dim r1 As Long
Dim r2 As Long
ScaleMode = vbPixels
' Создаем пустой регион
r1 = CreateRectRgn(0, 0, 0, 0)
' Для каждого контрола на форме
For Each Control In Form1.Controls
With Control
' Создаем регион в соответствии с положением и размером контрола
r2 = CreateRectRgn(.Left, .Top, .Left + .Width, .Top + .Height)
End With
' Комбинируем регионы
CombineRgn r1, r1, r2, RGN_OR
Next
' Привязываем регион к форме
SetWindowRgn hwnd, r1, True
' Освобождаем ресурсы
DeleteObject r1
DeleteObject r2
End Sub
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 37