Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Transparent forms in VB 6 3

Status
Not open for further replies.

hojoho

Technical User
Mar 8, 2003
44
US
Anyone know how to make a form transparent in VB 6.0.
Thanks
 
Hi,

a form can be made transparent in vb6 through the API.
the method below works pretty good for Windows 2000/XP,

in a module, add declarations:

Public Const GWL_EXSTYLE = (-20)
Public Const WS_EX_LAYERED = &H80000
Public Const LWA_ALPHA = &H2

Public Declare Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long) As Long

Public Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) _
As Long

Public Declare Function SetLayeredWindowAttributes Lib _
"user32" (ByVal hWnd As Long, ByVal crKey As Long, _
ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

add code to a button on the form:

Private Sub Command1_Click()

Dim TranslucenceLevel As Byte

TranslucenceLevel = 200

SetWindowLong Me.hWnd, GWL_EXSTYLE, WS_EX_LAYERED
SetLayeredWindowAttributes Me.hWnd, 0, TranslucenceLevel, LWA_ALPHA

End Sub


the value of the byte variable "TranslucenceLevel" controls
the degree of transparency of the form.

hope that helps!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top