Собственно subj...
то есть нужно чтобы при запуске видны были только label и все ...
настрока прозрачности окна в дальнейшем не понадобится...
Option Explicit
Public Declare Function CreateRectRgn Lib "gdi32" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
Public Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Public Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Public Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Public Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As BITMAPINFOHEADER, ByVal wUsage As Long) As Long
Public Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
Public Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
Public Const RGN_OR = 2
Private Type BITMAPINFOHEADER
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Public Function lGetRegion(ByVal lBackColor As Long, ByVal Picture As StdPicture, ByVal Frm As Form) As Long
Dim lRgn As Long
Dim lSkinRgn As Long
Dim lStart As Long
Dim lX As Long
Dim lY As Long
Dim ms As Long
Dim bi As BITMAPINFOHEADER, bits() As Long, hdc As Long
With bi
.biSize = LenB(bi)
.biWidth = Frm.ScaleX(Picture.Width, vbHimetric, vbPixels)
.biHeight = Frm.ScaleY(Picture.Height, vbHimetric, vbPixels)
.biPlanes = 1
.biBitCount = 32
.biCompression = 0
ReDim bits(0 To .biWidth - 1, 0 To .biHeight - 1)
hdc = CreateCompatibleDC(0)
GetDIBits hdc, Picture, 0, bi.biHeight, bits(0, 0), bi, 0
DeleteDC (hdc)
lSkinRgn = CreateRectRgn(0, 0, 0, 0)
For lX = 0 To .biHeight - 1
lY = 0
Do While lY < .biWidth
Do While lY < .biWidth
If bits(lY, lX) <> lBackColor Then Exit Do
lY = lY + 1
Loop
If lY < .biWidth Then
lStart = lY
Do While lY < .biWidth
If bits(lY, lX) = lBackColor Then Exit Do
lY = lY + 1
Loop
If lY > .biWidth Then lY = .biWidth
lRgn = CreateRectRgn(lStart, .biHeight - lX - 1, lY, .biHeight - lX)
CombineRgn lSkinRgn, lSkinRgn, lRgn, RGN_OR
DeleteObject lRgn
End If
Loop
Next
End With
lGetRegion = lSkinRgn
End Function
lRgn = lGetRegion(RGB(255, 0, 255), Picture, Me) ' Где RGB(255, 0, 255) - цвет кторый должен быть прозрачным
SetWindowRgn hWnd, lRgn, True
Jenizix писал(а):P.S. Я точно не помню кто написал ф-ию lGetRegion .. но вроде кто-то с VBStreets... или нет... на Sources.ru она тоже есть...
Option Explicit
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 Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Const RGN_OR = 2
Private Sub Form_Load()
Dim WindowRgn As Long ' тут будет храниться регион, по которому в последствии будет вырезано окно
Dim ctrlRgn As Long ' тут будет храниться регион текущео конрола
Dim ctrl As Control ' текущий контрол
WindowRgn = CreateRectRgn(0, 0, 0, 0) ' создаем пустой регион
On Error Resume Next
For Each ctrl In Controls ' перебираем все контролы на форме
ctrlRgn = CreateRectRgn(ctrl.Left / Screen.TwipsPerPixelX, ctrl.Top / Screen.TwipsPerPixelY, (ctrl.Left + ctrl.Width) / Screen.TwipsPerPixelX, (ctrl.Top + ctrl.Height) / Screen.TwipsPerPixelY) ' создаем регион текущего контрола
CombineRgn WindowRgn, WindowRgn, ctrlRgn, RGN_OR ' комбинируем его с регионом WindowRgn
Next
SetWindowRgn hWnd, WindowRgn, True ' вырезаем окно по региону WindowRgn
DeleteObject WindowRgn
DeleteObject ctrlRgn
End Sub
Сейчас этот форум просматривают: SemrushBot и гости: 72