View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Michel Pierron Michel Pierron is offline
external usenet poster
 
Posts: 214
Default Window's System Menu, can't remove menu

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

"Yury Lobanov" a écrit dans le message de
...
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