• Privacywetgeving
    Het is bij Helpmij.nl niet toegestaan om persoonsgegevens in een voorbeeld te plaatsen. Alle voorbeelden die persoonsgegevens bevatten zullen zonder opgaaf van reden verwijderd worden. In de vraag zal specifiek vermeld moeten worden dat het om fictieve namen gaat.

Menubar verbergen / tonen

Status
Niet open voor verdere reacties.
In een ander forum gevonden:
Code:
Option Explicit

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName 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 Const GWL_STYLE = (-16)
Private Const WS_CAPTION = &HC00000
Private Const WS_MAXIMIZEBOX = &H10000
Private Const WS_MINIMIZEBOX = &H20000
Private Const WS_SYSMENU = &H80000
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Enum ESetWindowPosStyles
    SWP_SHOWWINDOW = &H40
    SWP_HIDEWINDOW = &H80
    SWP_FRAMECHANGED = &H20
    SWP_NOACTIVATE = &H10
    SWP_NOCOPYBITS = &H100
    SWP_NOMOVE = &H2
    SWP_NOOWNERZORDER = &H200
    SWP_NOREDRAW = &H8
    SWP_NOREPOSITION = SWP_NOOWNERZORDER
    SWP_NOSIZE = &H1
    SWP_NOZORDER = &H4
    SWP_DRAWFRAME = SWP_FRAMECHANGED
    HWND_NOTOPMOST = -2
End Enum
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

Sub Title_Toggle()
    ShowTitleBar Application.DisplayFullScreen
End Sub

Sub ShowTitleBar(bShow As Boolean)
Dim lStyle As Long
Dim tRect As RECT
Dim sWndTitle As String
Dim xlhnd

'// Find window handle
sWndTitle = Application.Caption '// Old code used "Microsoft Excel - " & ActiveWindow.Caption
xlhnd = FindWindow("XLMAIN", sWndTitle) '// Old code did not have class name

'// Get the window's position:
GetWindowRect xlhnd, tRect

'// Show the Title bar ?
If Not bShow Then
    lStyle = GetWindowLong(xlhnd, GWL_STYLE)
    lStyle = lStyle And Not WS_SYSMENU
    lStyle = lStyle And Not WS_MAXIMIZEBOX
    lStyle = lStyle And Not WS_MINIMIZEBOX
    lStyle = lStyle And Not WS_CAPTION
Else
    lStyle = GetWindowLong(xlhnd, GWL_STYLE)
    lStyle = lStyle Or WS_SYSMENU
    lStyle = lStyle Or WS_MAXIMIZEBOX
    lStyle = lStyle Or WS_MINIMIZEBOX
    lStyle = lStyle Or WS_CAPTION
End If

SetWindowLong xlhnd, GWL_STYLE, lStyle
Application.DisplayFullScreen = Not bShow

'// Ensure the style is set and makes the xlwindow the
'// same size, regardless of the title bar.
SetWindowPos xlhnd, 0, tRect.Left, tRect.Top, tRect.Right - tRect.Left, tRect.Bottom - tRect.Top, SWP_NOREPOSITION Or SWP_NOZORDER Or SWP_FRAMECHANGED

End Sub

Sub Onzichtbaar_maken_Toolbars()
On Error Resume Next
With Application
.DisplayFullScreen = True
.CommandBars("Full Screen").Visible = False
.CommandBars("MyToolbar").Enabled = True
.CommandBars("MyToolbar").Visible = True
.CommandBars("Worksheet Menu Bar").Enabled = False
End With
ShowTitleBar (False)
On Error GoTo 0
End Sub

Sub Zichtbaar_maken_Toolbars()
On Error Resume Next
With Application
.DisplayFullScreen = False
.CommandBars("MyToolbar").Enabled = False
.CommandBars("Worksheet Menu Bar").Enabled = True
End With
ShowTitleBar (True)
On Error GoTo 0
End Sub
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan