|
-
Nov 5th, 2000, 06:24 AM
#1
Is there any way i can create semitransparent forms?
-
Nov 5th, 2000, 08:51 AM
#2
Fanatic Member
-
Nov 5th, 2000, 09:46 AM
#3
New Member
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....
-
Nov 6th, 2000, 06:42 AM
#4
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.
-
Nov 6th, 2000, 06:52 AM
#5
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.
-
Nov 6th, 2000, 07:25 AM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|