I have a form on my vb 6.0, i need to change the appearance. In the sense that, i can change its transparency or opacity of the way how the form looks. Is there any way possible i can do that ?

Recommended Answers

All 4 Replies

Below is the code. You will need 1 form to test it for now -

'Form1

Private Const WS_EX_LAYERED = &H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_COLORKEY = &H1
Private Const LWA_ALPHA = &H2

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 crColor As Long, ByVal nAlpha As Byte, ByVal dwFlags As Long) As Long
Private Sub Form_Load()

    ' enable layered window style
    Call SetWindowLong(Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED)

    ' set magenta to transparent
    ' set rest of window to 50% blend with the background

    Call SetLayeredWindowAttributes(Me.hwnd, RGB(255, 0, 255), 128, LWA_ALPHA Or LWA_COLORKEY)
    
End Sub

THANKS TONNESS, it worked

:) Only a pleasure. Happy coding...;)

Haha, Thank you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.