У меня возник вопрос.
Воспользовался кодом с одной из тем форума, который делает прозрачной только форму, а все контролы оставляет обычными.
Код работает, все хорошо.
Но в моем проекте форма которую надо сделать прозрачной не первая при загрузке. И при обработке кода в нужной форме прозрачность отображается коряво, т.е. контролы обрезаны.
Может кто подскажет как адоптировать данный код под мою задачу.
Заранее спасибо.
Вот пример кода:
- Код: Выделить всё
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
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