1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| Option Explicit
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Const WS_EX_TRANSPARENT = &H20&
Private Const GWL_EXSTYLE = (-20)
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_FRAMECHANGED = &H20
Private Declare Function SetBkMode Lib "gdi32" (ByVal hdc As Long, ByVal nBkMode As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Const TRANSPARENT = 1
Private Declare Function InvalidateRectLong Lib "user32" Alias "InvalidateRect" (ByVal hwnd As Long, ByVal lpRect As Long, ByVal bErase As Long) As Long
Public Sub FrameTransparent(ByVal fraThis As Control)
With koko
.BackStyle = 0
.BorderColor = Frame1.BorderColor
.BorderStyle = Frame1.BorderStyle
.Caption = Frame1.Caption
.Move 0, 0, Frame1.Width, Frame1.Height
.Visible = True
End With
With Frame1
.BorderStyle = fmBorderStyleNone
.Caption = ""
End With
Dim lehwnd As Long
lehwnd = Frame1.[_GethWnd]
Dim lExStyle As Long
lExStyle = GetWindowLong(lehwnd, GWL_EXSTYLE)
lExStyle = lExStyle Or WS_EX_TRANSPARENT
SetWindowLong lehwnd, GWL_EXSTYLE, lExStyle
SetBkMode GetDC(lehwnd), TRANSPARENT
SetWindowPos lehwnd, 0, 0, 0, 0, 0, SWP_NOMOVE + SWP_NOSIZE + SWP_FRAMECHANGED
InvalidateRectLong lehwnd, vbNull, True
End Sub
Private Sub CommandButton1_Click()
FrameTransparent Frame1
DoEvents
Frame1.ZOrder
Frame1.Top = Frame1.Top + 1
Frame1.Top = Frame1.Top - 1
reparer_deplacer
End Sub
Private Sub reparer_deplacer()
Dim c As Control
koko.ZOrder
For Each c In Frame1.Controls
If c.Name <> "koko" Then c.ZOrder
Next
End Sub |