Public Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Public Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As AppBarData) As Long
Public Type RECT: Left As Long: Top As Long: Right As Long: Bottom As Long: End Type
Public Type AppBarData: cbSize As Long: hwnd As Long: uCallbackMessage As Long: uEdge As Long: rc As RECT: lParam As Long: End Type
Sub fullscreen()
With Application: ScreenUpdating = False: .OnKey "{ESCAPE}", "": .DisplayFullScreen = True: .DisplayFormulaBar = False: End With
With ActiveWindow
.DisplayHeadings = False: .DisplayGridlines = True: .DisplayHorizontalScrollBar = False: .DisplayVerticalScrollBar = False: .DisplayWorkbookTabs = False
End With
SetWindowLongA FindWindowA(vbNullString, Application.Caption), -16, &H15070000
ShowWindow FindWindowA(vbNullString, Application.Caption), 3
DrawMenuBar FindWindowA(vbNullString, Application.Caption)
ChangeTaskBar 1
'ShowWindow hwnd, 3
End Sub
Sub Nofullscreen()
With Application: ScreenUpdating = False: .OnKey "{ESCAPE}", "{ESCAPE}": .DisplayFullScreen = False: .DisplayFormulaBar = True: End With
With ActiveWindow
.DisplayHeadings = True: .DisplayGridlines = True: .DisplayHorizontalScrollBar = True: .DisplayVerticalScrollBar = True: .DisplayWorkbookTabs = True
End With
ChangeTaskBar 0
SetWindowLongA FindWindowA(vbNullString, Application.Caption), -16, &H15CF0000
DrawMenuBar FindWindowA(vbNullString, Application.Caption)
End Sub
'Applique les propriétés à la barre des taches
'Mode = 0 : voir la barre des tâche
'Mode = 1 : cache la barre des tâches
Public Function ChangeTaskBar(Mode As Long)
Dim BarDt As AppBarData, ret As Long
'Entrée des paramètres
BarDt.cbSize = Len(BarDt): BarDt.hwnd = FindWindowA("shell_traywnd", ""): BarDt.lParam = Mode
'Applique
ret = SHAppBarMessage(&HA, BarDt)
If ret = 0 Then
Call MsgBox("erreur lors de l'appel de SHAppBarMessage", vbCritical + vbOKOnly, "Erreur")
End If
End Function