Window's System Menu, can't remove menu

  • Thread starter Thread starter Yury Lobanov
  • Start date Start date
Y

Yury Lobanov

Not to find how to trap window closing i'm trying to disable "X"-button,
and System menu. With API.

API's "RemoveMenu" works with Forms but not with Worksheet Windows!!!
"X"-button can be disabled, but System Menu - can't!!

is it impossible to remove items of System Menu of a Worksheet Window????

Yury
 
I think people typically use Tools, Protection, Protect Workbook, Windows to
get to where you want to go.
 
Yuri,

If you make your userform full screen, *none* of the toolbars are
accessible.
Disable the "X" on your form and the only way a user can get out of the form
is to click your Exit button on the form.

Private Sub UserForm_Initialize()
With Application
Me.Top = .Top
Me.Left = .Left
Me.Height = .Height
Me.Width = .Width
End With
End Sub

HTH
Henry
 
Hi Yuri;
You can try (in the ThisWorkbook module):
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String _
, ByVal lpsz2 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 Sub Workbook_Open()
Application.WindowState = xlMaximized
With ActiveWindow
.WindowState = xlNormal
.Top = 0: .Left = 0
.Height = Application.UsableHeight
.Width = Application.UsableWidth
End With
Dim hWnd(1 To 3) As Long
hWnd(1) = FindWindow("XLMAIN", Application.Caption)
hWnd(2) = FindWindowEx(hWnd(1), ByVal 0&, "XLDESK", vbNullString)
hWnd(3) = FindWindowEx(hWnd(2), ByVal 0&, "EXCEL7", ActiveWindow.Caption)
SetWindowLong hWnd(3), -16, GetWindowLong(hWnd(3), -16) And Not &HC00000
End Sub

MP
 
Back
Top