The document contains VBA code that utilizes Windows API functions to manipulate user forms in a graphical user interface. It includes functions to make a user form transparent and to hide the title bar and border of the form. The code is structured to support both 32-bit and 64-bit versions of VBA.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
3 views
Modul_HideTitleBar
The document contains VBA code that utilizes Windows API functions to manipulate user forms in a graphical user interface. It includes functions to make a user form transparent and to hide the title bar and border of the form. The code is structured to support both 32-bit and 64-bit versions of VBA.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2
#If VBA7 Then
Private Declare PtrSafe Function FindWindow Lib "user32" _
Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long
Private Declare PtrSafe Function GetWindowLong Lib "user32" _
Alias "GetWindowLongA" ( _ ByVal hWnd As Long, _ ByVal nIndex As Long) As Long
Private Declare PtrSafe Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" ( _ ByVal hWnd As Long, _ ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long
Private Declare PtrSafe Function DrawMenuBar Lib "user32" ( _
ByVal hWnd As Long) As Long
Private Declare PtrSafe Function SetLayeredWindowAttributes Lib "user32" ( _
ByVal hWnd As Long, _ ByVal crKey As Long, _ ByVal bAlpha As Byte, _ ByVal dwFlags As Long) As Long
#Else
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 DrawMenuBar Lib "user32" ( _
ByVal hWnd 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
#End If
Private Const GWL_STYLE As Long = (-16)
Private Const GWL_EXSTYLE As Long = (-20) Private Const WS_CAPTION As Long = &HC00000 Private Const WS_EX_DLGMODALFRAME As Long = &H1
Private Const WS_EX_LAYERED = &H80000
Private Const LWA_COLORKEY = &H1 Private Const LWA_ALPHA = &H2 Private m_sngDownX As Single Private m_sngDownY As Single Sub MakeUserformTransparent(frm As Object, Optional Color As Variant) Dim formhandle As Long Dim bytOpacity As Byte formhandle = FindWindow(vbNullString, Me.Caption) If IsMissing(Color) Then Color = 1257038 bytOpacity = 100 SetWindowLong formhandle, GWL_EXSTYLE, GetWindowLong(formhandle, GWL_EXSTYLE) Or WS_EX_LAYERED Me.BackColor = Color SetLayeredWindowAttributes formhandle, Color, bytOpacity, LWA_COLORKEY End Sub Sub HideTitleBarAndBorder(frm As Object) Dim lngWindow As Long Dim lFrmHdl As Long lFrmHdl = FindWindow(vbNullString, frm.Caption) lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE) lngWindow = lngWindow And (Not WS_CAPTION) SetWindowLong lFrmHdl, GWL_STYLE, lngWindow lngWindow = GetWindowLong(lFrmHdl, GWL_EXSTYLE) lngWindow = lngWindow And Not WS_EX_DLGMODALFRAME SetWindowLong lFrmHdl, GWL_EXSTYLE, lngWindow DrawMenuBar lFrmHdl End Sub