Results 1 to 3 of 3

Thread: Form Transparency

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2007
    Posts
    85

    Form Transparency

    Hi guys, I'm currently using this to make my form semi-transparent. and it's working fine, for it's meant to be used for.

    Code:
    Option Explicit
    
    Private Const GWL_EXSTYLE = (-20)
    Private Const WS_EX_LAYERED = &H80000
    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 crKey As Long, _
        ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    
    Public Function TransForm(Form As Form, TransLevel As Byte) As Boolean
        SetWindowLong Form.hWnd, GWL_EXSTYLE, WS_EX_LAYERED
        SetLayeredWindowAttributes Form.hWnd, 0, TransLevel, LWA_ALPHA
        TransForm = Err.LastDllError = 0
    End Function
    
    Private Sub Form_Load()
        TransForm Me, 200
    End Sub
    But I now need to be able to control the transparency of the form and the controls separately, rather than all in one. Anyone got any ideas?

    Syrillia

  2. #2
    Only Slightly Obsessive jemidiah's Avatar
    Join Date
    Apr 2002
    Posts
    2,431

    Re: Form Transparency

    While horrendously inefficient and clunky, if all else fails you could put each control on its own form and control each form's transparency.
    The time you enjoy wasting is not wasted time.
    Bertrand Russell

    <- Remember to rate posts you find helpful.

  3. #3
    Lively Member
    Join Date
    Nov 2007
    Location
    Rochester, NY
    Posts
    111

    Re: Form Transparency

    Or just have a 'Settings' form available, with frames and a slider calling each forms transparency.
    Please use the search function prior to posting a question and see if someone's already answered it.
    -If I helped you, please rate me, as I'd do the same for you =)
    -Remember to select the Resolved option for your post when you've gotten the answers you need.

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