Weitere Möglichkeit: Kreuz nicht zulassen
26.10.2010 09:06:42
Martin
Hallo Holger,
wenn das Kreuz einfach weg soll, dann nimm folgenden Code:
Option Explicit
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetWindowLong Lib "user32.dll" Alias "GetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function DrawMenuBar Lib "user32.dll" ( _
ByVal hWnd As Long) As Long
Private Const GWL_STYLE = -&H10
Private Const WS_SYSMENU = &H80000
Private Const GC_CLASSNAMEMSEXCELFORM = "ThunderDFrame"
Private Sub UserForm_Activate()
Dim hWndForm As Long
hWndForm = FindWindow(GC_CLASSNAMEMSEXCELFORM, Me.Caption)
If hWndForm 0 Then
SetWindowLong hWndForm, GWL_STYLE, GetWindowLong(hWndForm, GWL_STYLE) And Not _
WS_SYSMENU
DrawMenuBar hWndForm
End If
End Sub
Wenn das Kreuz nur nicht anwählbar sein soll, dann nimm dieses Code:
Option Explicit
Private Declare Function DeleteMenu Lib "user32.dll" ( _
ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Private Declare Function DrawMenuBar Lib "user32.dll" ( _
ByVal hwnd As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetSystemMenu Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal bRevert As Long) As Long
Private Const GC_CLASSNAMEMSEXCELFORM = "ThunderDFrame"
Private Const MF_BYCOMMAND = &H0
Private Const SC_CLOSE = &HF060
Private Sub UserForm_Activate()
Dim hWndForm As Long, hWndMenu As Long
hWndForm = FindWindow(GC_CLASSNAMEMSEXCELFORM, Me.Caption)
If hWndForm 0 Then
hWndMenu = GetSystemMenu(hWndForm, 0&)
If hWndMenu 0 Then
DeleteMenu hWndMenu, SC_CLOSE, MF_BYCOMMAND
DrawMenuBar hWndForm
End If
End If
End Sub
Viele Grüße
Martin