AW: Deaktivieren Schließkreuz für einzelnes Blatt
28.07.2007 14:43:38
Rudi
Hallo, Rainer!
Ich habe inzwischen einen API-Code gefunden. Er stammt aus dem threat 688847 vom 29.10.2005, 22:54:00 h (Nepumuk, 30.10.2005,10:23.27 h) und soll beim Aktivieren des Workbooks das Ausblenden des Schließkreuzes bewirken:
' **********************************************************************
' Modul: DieseArbeitsmappe Typ: Element der Mappe(Sheet, Workbook, ...)
' **********************************************************************
Option Explicit
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 Const GWL_STYLE = -&H10
Private Const WS_SYSMENU = &H80000
Private Const gcClassnameMSExcel = "XLMAIN"
Private Sub Workbook_Activate()
Dim lHwnd As Long
lHwnd = FindWindow(gcClassnameMSExcel, Application.Caption)
SetWindowLong lHwnd, GWL_STYLE, GetWindowLong(lHwnd, GWL_STYLE) And Not WS_SYSMENU
DrawMenuBar lHwnd
End Sub
Private Sub Workbook_Deactivate()
Dim lHwnd As Long
lHwnd = FindWindow(gcClassnameMSExcel, Application.Caption)
SetWindowLong lHwnd, GWL_STYLE, GetWindowLong(lHwnd, GWL_STYLE) Or WS_SYSMENU
DrawMenuBar lHwnd
End Sub
Ich habe den Code noch nicht probiert, gehe aber davon aus, dass er läuft.
Mit
SetWindowLong lHwnd, GWL_STYLE, GetWindowLong(lHwnd, GWL_STYLE) And Not WS_SYSMENU
wird das Schließkreuz vermutlich entfernt, wobei ich leider keinen Überblick habe, was sich unter der Adresse WS_SYSMENU = &H80000 konkret verbirgt, bzw. welche Merkmale man sonst noch auf diesem Weg verändern kann....
Damit wäre mein Schließkreuz-Problem gelöst. Für das Schließen der Seite ist dann nur noch eine Schaltfläche im Worksheet erforderlich und ein geordneter Programmabschluss ist möglich.
Gruß -Rudi-