Application.WindowState = xlMaximized
Option Explicit' Origine : fred - chapeaux.ronds@wanadoo.fr
Private Declare Function DeleteMenu Lib "user32" (ByVal _
hMenu As Long, ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal _
hwnd As Long, ByVal bRevert As Long) 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 Const GWL_STYLE = (-16)
Private Const MF_BYCOMMAND = &H0&
Private Const SC_MINIMIZE = &HF020
Private Const SC_MAXIMIZE = &HF030
Private Const WS_MAXIMIZEBOX = &H10000
Private Sub Désactiver_Maximiser()
Dim hMenu As Long, k As Long
hMenu = GetSystemMenu(Application.hwnd, False)
k = DeleteMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
k = GetWindowLong(Application.hwnd, GWL_STYLE)
k = k Xor WS_MAXIMIZEBOX
SetWindowLong Application.hwnd, GWL_STYLE, k
End Sub
Private Sub Réactiver_Maximiser()
Dim hMenu As Long, k As Long
hMenu = GetSystemMenu(Application.hwnd, True)
k = DeleteMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
k = GetWindowLong(Application.hwnd, GWL_STYLE)
k = k Xor WS_MAXIMIZEBOX
SetWindowLong Application.hwnd, GWL_STYLE, k
End Sub
Option Explicit
Declare Function GetWindowLong Lib "user32" Alias _
"GetWindowLongA" (ByVal hwnd As Long, ByVal _
nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias _
"SetWindowLongA" (ByVal hwnd As Long, ByVal _
nIndex As Long, ByVal dwNewLong As Long) As Long
Sub Désactiver()
Application.WindowState = xlMaximized
SetWindowLong Application.hwnd, -16, GetWindowLong(Application.hwnd, -16) And Not &H10000
End Sub
Sub Activer()
Application.WindowState = xlMaximized
SetWindowLong Application.hwnd, -16, GetWindowLong(Application.hwnd, -16) Or &H10000
End Sub
Private Sub Workbook_Open()
Module5.Desactiver
Application.WindowState = xlMaximized
End Sub
Sub Workbook_BeforeClose(Cancel As Boolean)
Module5.Activer
End Sub
Bonsoir David84,
tout d'abord merci pour tes interventions, pour le premier code, j'ai supprimé les "Private" pour que je puisse l'affecter à des boutons, alors j'ai intégré Désactiver_Maximiser à Workbook_Open() mais rien ne se passe.
pour le deuxième, aussi la même chose
je suis sous Excel2010
@ te relire
Exact mais la question initiale estPar contre, le double clique sur la barre du haut continue à fenêtrer ou à maximiser à fenêtre.
et là c'est le cas...ce qui ne veut pas dire qu'il n'y a pas d'échappatoire...dont cette possibilité.je veux bien démarrer un classeur Excel avec fenêtre agrandie et en désactivant l’icône de restauration de la fenêtre
Option Explicit
Declare Sub GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT)
Declare Sub ClientToScreen Lib "user32" (ByVal hwnd As Long, lpPoint As POINT)
Declare Sub ClipCursor Lib "user32" (lpRect As Any)
Declare Sub OffsetRect Lib "user32" (lpRect As RECT, ByVal x As Long, ByVal y As Long)
Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Type POINT
x As Long
y As Long
End Type
Sub Désactiver2()
Dim hwnd As Long
Dim Zone As RECT
Dim Pos As POINT
hwnd = Application.hwnd
Application.DisplayFullScreen = True
Application.OnKey "{ESC}", ""
GetClientRect hwnd, Zone
Pos.x = Zone.Left
Pos.y = Zone.Top
ClientToScreen hwnd, Pos
OffsetRect Zone, Pos.x, Pos.y
ClipCursor Zone
End Sub
Sub Réactiver2()
Application.DisplayFullScreen = False
Application.OnKey "{ESC}"
ClipCursor ByVal 0&
End Sub
Sub Désactiver()
SetWindowLong Application.hwnd, -16, GetWindowLong(Application.hwnd, -16) And Not &H10000
Application.WindowState = xlNormal
Application.WindowState = xlMaximized
End Sub
Sub Activer()
SetWindowLong Application.hwnd, -16, GetWindowLong(Application.hwnd, -16) Or &H10000
Application.WindowState = xlNormal
Application.WindowState = xlMaximized
End Sub