Is there any way i can create semitransparent forms?
Printable View
Is there any way i can create semitransparent forms?
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....
Thanks oetje for the link.
But there is one problem, that is whenever i move the form it takes some time to refresh.
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.
There sure is!Quote:
Originally posted by andromedia
This topic sounds quite interesting to me... but is there anyway to do it using Alpha-blending in Windows 2000?
Windows 2000 introduced the SetLayeredWindowAttributes API function that you can use for this.
The following code only works on Win2000.
Copy the above code to a BAS module.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
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!