Results 1 to 6 of 6

Thread: Transparent Form

Threaded View

  1. #1

    Thread Starter
    Frenzied Member d3gerald's Avatar
    Join Date
    Jan 2006
    Posts
    1,348

    Transparent Form

    SetTrans procedure sets a form transparent depending on your passed value
    julst call it like this

    settrans frm1.hwnd, 100

    VB Code:
    1. Option Explicit
    2.  
    3. Public Const GWL_EXSTYLE As Long = -20
    4. Public Const WS_EX_LAYERED As Long = &H80000
    5. Public Const LWA_ALPHA As Long = &H2
    6.  
    7. Public Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    8. Public Declare Function SetLayeredWindowAttributes Lib "user32.dll" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    9. Public Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    10. Public Declare Function SetParent Lib "user32.dll" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
    11.  
    12. Public Sub SetTrans(ByVal OB_Hwnd As Long, ByVal OB_Val As Integer)
    13.     Dim FTransVal As Long
    14.     Dim Attrib As Long
    15.     Attrib = GetWindowLong(OB_Hwnd, GWL_EXSTYLE)
    16.     SetWindowLong OB_Hwnd, GWL_EXSTYLE, Attrib Or WS_EX_LAYERED
    17.     SetLayeredWindowAttributes OB_Hwnd, RGB(0, 0, 0), OB_Val, LWA_ALPHA
    18.     FTransVal = OB_Val
    19.     Exit Sub
    20. End Sub
    Last edited by d3gerald; Apr 17th, 2006 at 09:17 PM.
    On error goto Trap

    Trap:
    in case of emergency, drop the case...

    ****************************************
    If this post has been resolved. Please mark it as "Resolved" by going through the "Thread Tools" above and clicking on the "Mark Thread Resolved " option.
    if a post is helpful to you, Please Rate it by clicking on the Rate link right below the avatar

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width