Results 1 to 6 of 6

Thread: AlphaBlending Form

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Posts
    20
    Hi!!!
    Can I mke a Form in VB 5 quite transparent?? I mean if behind of the form is the desktop can I see that with alphablending? And I don't want to take a picture of the thing behind of the form and put it as image of the form
    for example can I see a clock behind the form running??
    Thanks
    Wolverine

  2. #2
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Only if you have Windows 2000 (which supports translucant windows), otherwise you'll have to fake it, which about 99% of the time looks horrible and 102% which won't update what's behind it.

    Btw, here's the code for Win2K, I haven't tested it yet, but it's copied straight from the API Guide, so it should work:

    Code:
    Const LWA_COLORKEY = &H1
    Const LWA_ALPHA = &H2
    Const GWL_EXSTYLE = (-20)
    Const WS_EX_LAYERED = &H80000
    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
    
    Private Sub Form_Load()
        'KPD-Team 2000
        'URL: http://www.allapi.net/
        'E-Mail: [email protected]
        Dim Ret As Long
        'Set the window style To 'Layered'
        Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
        Ret = Ret Or WS_EX_LAYERED
        SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret
        'Set the opacity of the layered window To 128
        SetLayeredWindowAttributes Me.hWnd, 0, 128, LWA_ALPHA
    End Sub
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  3. #3
    Lively Member Optic's Avatar
    Join Date
    Mar 2001
    Location
    I'm everywhere and nowhere, I'm inside your computer and inside your mind. You can't escape me for I am vision.
    Posts
    117
    Is there any way to use this code on mdichildren or on controls in your form. I want to have a form with an image on it and all the controls on top to be translucent so you can see the image.

  4. #4
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Neither MDI children nor individual controls worked with my tests...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

  5. #5
    Lively Member Optic's Avatar
    Join Date
    Mar 2001
    Location
    I'm everywhere and nowhere, I'm inside your computer and inside your mind. You can't escape me for I am vision.
    Posts
    117
    Is there any other way I can do this then?

  6. #6
    Fanatic Member PsychoMark's Avatar
    Join Date
    Feb 2001
    Location
    Netherlands
    Posts
    540
    Draw them yourself, but that's a lot of work...
    Teaudirenopossum.Musasapientumfixaestinaure.
    (I can't hear you. There's a banana in my ear)

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