Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Const SW_SHOW = 5
Private Const WS_BORDER = &H800000
Private Const WS_CAPTION = &HC00000
Private Const GWL_STYLE = (-16)
Private Sub UserForm_Activate()
Dim lngFormHwnd As Long, lngFormStyle As Long
'First, make sure the form has it's BorderStyle set to None
Me.BorderStyle = fmBorderStyleNone
'Get the Windows handle of the userform
If Application.Version< "9.0" Then
lngFormHwnd = FindWindow("THUNDERXFRAME", Me.Caption)
Else
lngFormHwnd = FindWindow("THUNDERDFRAME", Me.Caption)
End If
'Get the form's window style
lngFormStyle = GetWindowLong(lngFormHwnd, GWL_STYLE)
'Set a new style without a border
lngFormStyle = lngFormStyle And Not WS_BORDER
'Set the new style i.e. without border
SetWindowLong lngFormHwnd, GWL_STYLE, lngFormStyle
'Refresh
DrawMenuBar lngFormHwnd
'This line doesn't appear to do anything
'ShowWindow lngFormHwnd, SW_SHOW
End Sub