Click to See Complete Forum and Search --> : Opaque Form
SeanK
Oct 30th, 2002, 12:54 PM
Does any know how to make a form Opaque or translucent (NOT transparent)?
Hack
Oct 30th, 2002, 01:03 PM
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: KPDTeam@Allapi.net
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
davidrobin
Nov 4th, 2002, 06:22 AM
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.
davidrobin
Nov 4th, 2002, 08:31 AM
Is it possible to make just the form transparent or semi transparent without affecting the controls on it?
:D
Electroman
Nov 4th, 2002, 08:54 AM
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.
cyborg
Nov 4th, 2002, 04:21 PM
that code didnt work for me...
cyborg
Nov 4th, 2002, 04:22 PM
i get the error: "cant find dll entry point SetLayeredWindowAttributes in user32"
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.