Gruppe
API
Problem
Eine UserForm ohne Schließkreuz soll erstellt werden.
StandardModule: Modul1
Sub CallForm()
frmCross.Show
End Sub
ClassModule: frmCross
Private Const GWL_STYLE = (-16)
Private Const WS_SYSMENU = &H80000
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 Sub cmdCancel_Click()
Unload Me
End Sub
Private Sub UserForm_Activate()
'Code von Nepumuk
Dim xl_hwnd, lStyle
xl_hwnd = FindWindow(vbNullString, Me.Caption)
If xl_hwnd <> 0 Then
lStyle = GetWindowLong(xl_hwnd, GWL_STYLE)
lStyle = SetWindowLong(xl_hwnd, GWL_STYLE, lStyle And Not WS_SYSMENU)
DrawMenuBar xl_hwnd
End If
End Sub