Results 1 to 6 of 6

Thread: Semitransparent form

  1. #1
    Guest

    Lightbulb

    Is there any way i can create semitransparent forms?

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    Oetje
    oetje@home.nl
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3
    New Member
    Join Date
    Sep 2000
    Posts
    11
    This topic sounds quite interesting to me... but is there anyway to do it using Alpha-blending in Windows 2000? I've seen this in Winamp's AVS, where u can make the window _really_ translucent, and somehow the effect is quite different from the one shown in the previous post....

  4. #4
    Guest

    Talking That link helped...

    Thanks oetje for the link.
    But there is one problem, that is whenever i move the form it takes some time to refresh.

  5. #5
    Guest
    Of course it is slow. VB is slow, and that's slow even with C/C++ (with a slow machine like I'm having). Please only use only if you really think you need it if you share your program.

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Originally posted by andromedia
    This topic sounds quite interesting to me... but is there anyway to do it using Alpha-blending in Windows 2000?
    There sure is!
    Windows 2000 introduced the SetLayeredWindowAttributes API function that you can use for this.
    The following code only works on Win2000.
    Code:
    Private Declare Function SetLayeredWindowAttributes _
     Lib "user32" ( _
     ByVal hWnd As Long, _
     ByVal crKey As Long, _
     ByVal bAlpha As Long, _
     ByVal dwFlags As Long) As Long
    
    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 Const GWL_EXSTYLE = (-20)
    Private Const WS_EX_LAYERED = &H80000
    
    Public Sub Translution(ByVal hWnd As Long, ByVal Alpha As Byte)
        Dim lngStyle As Long
        
        lngStyle = GetWindowLong(hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED
        If SetWindowLong(hWnd, GWL_EXSTYLE, lngStyle) Then
            SetLayeredWindowAttributes hWnd, 0, CLng(Alpha), LWA_ALPHA
        End If
    End Sub
    Copy the above code to a BAS module.
    Then call the Translution sub and pass the hWnd of any form. The Alpha argument should be a value of 0 - 255 where 0 is invisible and 255 is solid.

    Good luck!

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