By Dali-Inc SoftwaresCreated 03 Jan 2012, Modified 05 Jan 2012
My Rating:
Not Rated

Transparent Form

Language:  VB


Windows XP Yes Windows 2003 Yes
Windows 2000 Yes Windows NT Yes
Vista Yes Windows 2008 Yes

make your user form transparent. value starts from 200 and below.. the lower the value the more transparent it becomes.., the value should not exceed 200, otherwise it generates an error..


Line Numbers: On  Off      Plain Text
'paste code in module
Option Explicit
Private Const GWL_EXSTYLE = (-20)
Private Const WS_EX_LAYERED = &H80000
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 Declare Function SetLayeredWindowAttributes Lib _
    "user32" (ByVal hWnd As Long, ByVal crKey As Long, _
    ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

Public Function TransForm(Form As Form, TransLevel As Byte) As Boolean
    SetWindowLong Form.hWnd, GWL_EXSTYLE, WS_EX_LAYERED
    SetLayeredWindowAttributes Form.hWnd, 0, TransLevel, LWA_ALPHA
    TransForm = err.LastDllError = 0
End Function

'paste this code on form load
Private Sub Form_Load()
On Error Resume Next
TransForm Me, 200
' the value should not be more that 200, but it can be less than 200
End Sub


Got a useful script? Click here to upload!


  Post Comment
Order By:  
User Comments
Be the first to post a comment!