VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

turn a color on form transparent

Matt  (8 Submissions)   Windows API Call/Explanation   Visual Basic 3.0   Beginner   Wed 3rd February 2021

Turn a certain color on the form or controls transparent

Inputs
Send the sub in module the form name or just me and the color to make transparent TransForm Me, rgb(0,0,0) Makes everything black on the form transparent

Side Effects
none yet

API Declarations
'windows 2000 only
'in module
'constants for transparency subs
Const LWA_COLORKEY = &H1
Const LWA_ALPHA = &H2
Const GWL_EXSTYLE = (-20)
Const WS_EX_LAYERED = &H80000
'api's for transparency subs
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
Public Sub TransForm(frmTrans As Form, transColor As Long)
Dim Ret As Long
Ret = GetWindowLong(frmTrans.hWnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED
SetWindowLong frmTrans.hWnd, GWL_EXSTYLE, Ret
SetLayeredWindowAttributes frmTrans.hWnd, transColor, 255, LWA_COLORKEY
End Sub
Public Sub untransForm(frmunTrans As Form)
Dim Ret As Long
Ret = GetWindowLong(frmunTrans.hWnd, GWL_EXSTYLE)
Ret = Ret Or WS_EX_LAYERED
SetWindowLong frmunTrans.hWnd, GWL_EXSTYLE, Ret
SetLayeredWindowAttributes frmunTrans.hWnd, 0, 255, LWA_ALPHA
End Sub

Rate turn a color on form transparent (3(3 Vote))
turn a color on form transparent.bas

turn a color on form transparent Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters