SetTrans procedure sets a form transparent depending on your passed value
julst call it like this
settrans frm1.hwnd, 100
VB Code:
Option Explicit Public Const GWL_EXSTYLE As Long = -20 Public Const WS_EX_LAYERED As Long = &H80000 Public Const LWA_ALPHA As Long = &H2 Public Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Public Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long Public Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long Public Sub SetTrans(ByVal OB_Hwnd As Long, ByVal OB_Val As Integer) Dim FTransVal As Long Dim Attrib As Long Attrib = GetWindowLong(OB_Hwnd, GWL_EXSTYLE) SetWindowLong OB_Hwnd, GWL_EXSTYLE, Attrib Or WS_EX_LAYERED SetLayeredWindowAttributes OB_Hwnd, RGB(0, 0, 0), OB_Val, LWA_ALPHA FTransVal = OB_Val Exit Sub End Sub




Reply With Quote