Consulting

Results 1 to 2 of 2

Thread: Solved: Transparent UserForm

  1. #1

    Solved: Transparent UserForm

    Another question!

    Is there any way to make a userform Transparent - My userform currently sits on top of all the other windows like an Always on Top. But just wondering if there is a way to make this fade slightly so when I'm in IE or Word etc it doesn't hide what I'm looking at.

  2. #2
    Rah sorted

    [vba]
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    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 crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long

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

    Public hWnd As Long

    Private Sub UserForm_Initialize()
    Dim bytOpacity As Byte
    bytOpacity = 192 ' variable keeping opacity setting
    hWnd = FindWindow("ThunderDFrame", Me.Caption)
    Call SetWindowLong(Me.hWnd, GWL_EXSTYLE, GetWindowLong(Me.hWnd, GWL_EXSTYLE) Or WS_EX_LAYERED)
    Call SetLayeredWindowAttributes(Me.hWnd, 0, bytOpacity, LWA_ALPHA)
    End Sub
    [/vba]

Posting Permissions

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