Results 1 to 22 of 22

Thread: Making A Form Transparent (But with visible controls)

Threaded View

  1. #1

    Thread Starter
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Making A Form Transparent (But with visible controls)

    To make form transparent, but controls visible:
    VB Code:
    1. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
    2.                 ByVal hwnd As Long, _
    3.                 ByVal nIndex As Long) As Long
    4.  
    5. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" ( _
    6.                 ByVal hwnd As Long, _
    7.                 ByVal nIndex As Long, _
    8.                 ByVal dwNewLong As Long) As Long
    9.                
    10. Private Declare Function SetLayeredWindowAttributes Lib "user32" ( _
    11.                 ByVal hwnd As Long, _
    12.                 ByVal crKey As Long, _
    13.                 ByVal bAlpha As Byte, _
    14.                 ByVal dwFlags As Long) As Long
    15.  
    16. Private Const GWL_STYLE = (-16)
    17. Private Const GWL_EXSTYLE = (-20)
    18. Private Const WS_EX_LAYERED = &H80000
    19. Private Const LWA_COLORKEY = &H1
    20. Private Const LWA_ALPHA = &H2
    21.  
    22. Private Sub Form_Load()
    23.     Me.BackColor = vbCyan
    24.     SetWindowLong Me.hwnd, GWL_EXSTYLE, GetWindowLong(Me.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED
    25.     SetLayeredWindowAttributes Me.hwnd, vbCyan, 0&, LWA_COLORKEY
    26. End Sub
    It actually just makes anything coloured vbCyan to become transparent.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width