Questo esempio è applicato a tre TextBox, ma si può applicare ad altri controlli:Originariamente inviato da D team software
C è la possibilità di dare una trasparenza ai controlli (ad esempoio text o anche button) in modo tale che si veda l immagine di sfondo della form?
Const LWA_COLORKEY = &H1
Const LWA_ALPHA = &H2
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
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 SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Sub Form_Load()
Dim Ret As Long
Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED
SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret
SetLayeredWindowAttributes Me.hWnd, 0, 128, LWA_ALPHA
SetLayeredWindowAttributes Form1.hWnd, &HFFFFFF, 0, LWA_COLORKEY
Ret = GetWindowLong(Text1.hWnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED
SetWindowLong Text1.hWnd, GWL_EXSTYLE, Ret
SetLayeredWindowAttributes Text1.hWnd, &HC000&, 0, LWA_COLORKEY
Ret = GetWindowLong(Text2.hWnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED
SetWindowLong Text2.hWnd, GWL_EXSTYLE, Ret
SetLayeredWindowAttributes Text2.hWnd, &HFF&, 0, LWA_COLORKEY
Ret = GetWindowLong(Text3.hWnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED
SetWindowLong Text3.hWnd, GWL_EXSTYLE, Ret
SetLayeredWindowAttributes Text3.hWnd, &H8000000F, 0, LWA_COLORKEY
End Sub