Results 1 to 7 of 7

Thread: Opaque Form

  1. #1

    Thread Starter
    Frenzied Member SeanK's Avatar
    Join Date
    May 2002
    Location
    Boston MA
    Posts
    1,160

    Opaque Form

    Does any know how to make a form Opaque or translucent (NOT transparent)?
    Beantown Boy
    Please use [highlight=vb]your code goes in here[/highlight] tags when posting code.
    When you have received an answer to your question, please mark it as resolved using the Thread Tools menu.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Try this...

    VB Code:
    1. Const LWA_COLORKEY = &H1
    2. Const LWA_ALPHA = &H2
    3. Const GWL_EXSTYLE = (-20)
    4. Const WS_EX_LAYERED = &H80000
    5. Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
    6. Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    7. Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hWnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    8. Private Sub Form_Load()
    9.     'KPD-Team 2000
    10.     'URL: [url]http://www.allapi.net/[/url]
    11.     'E-Mail: [email][email protected][/email]
    12.     Dim Ret As Long
    13.     'Set the window style to 'Layered'
    14.     Ret = GetWindowLong(Me.hWnd, GWL_EXSTYLE)
    15.     Ret = Ret Or WS_EX_LAYERED
    16.     SetWindowLong Me.hWnd, GWL_EXSTYLE, Ret
    17.     'Set the opacity of the layered window to 128
    18.     SetLayeredWindowAttributes Me.hWnd, 0, 128, LWA_ALPHA
    19. End Sub

  3. #3
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    How on earth do you find somehting like this out. The only way must be to spend hours reading an api manual.

    This is excellent and something I have been looking for for ages.
    thanks Hack.

  4. #4
    Fanatic Member
    Join Date
    Oct 1999
    Location
    England
    Posts
    982
    Is it possible to make just the form transparent or semi transparent without affecting the controls on it?


  5. #5
    Ex-Super Mod'rater Electroman's Avatar
    Join Date
    Sep 2000
    Location
    Newcastle, England
    Posts
    4,349
    I'mnot perfectly sure bout this but shouldn't you be able to pass the hWnd of the controls in the place of Me.hWnd and set it to the value for normal forms? I can't remember if all controls have a hWnd cos i'm not at my PC with VB on so I can't check but I think they do.

    So I couldn't be of anymore help.
    When your thread has been resolved please edit the original post in the thread ()
    and amend "-[RESOLVED]-" to the end of the title and change the icon to , Thank you.

    When posting Code use the [VBCode]Code Here[/VBCode] tags to be able to use the code highlighting.

  6. #6
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    that code didnt work for me...
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

  7. #7
    Frenzied Member cyborg's Avatar
    Join Date
    May 2000
    Location
    Sweden
    Posts
    1,755
    i get the error: "cant find dll entry point SetLayeredWindowAttributes in user32"
    Check out the FAQ and do a search before you post.
    My tutorials: Anti-Alias Pixels, Accurate Game Loop, Resource File

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