Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

proble me handel

1 réponse
Avatar
gérard
bonjour


les declaration sont faites dans le module

Public Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal
nPosition As Long, ByVal wFlags As Long) As Long
Public Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long,
ByVal bRevert As Long) As Long

Public Declare Function GetWindowlong Lib "user32" Alias "GetWindowLongA"
(ByVal hWnd As Long, nIndex As Long) As Long
Public Declare Function SetWindowlong Lib "user32" Alias "SetWindowLongA"
(ByVal hWnd As Long, nIndex As Long, ByVal dwNewLong As Long) As Long

Public Const GWL_STYLE = (-16)
Public Const MF_BYCOMMAND = &H0&
Public Const MF_BYPOSITION = &H400
Public Const SC_MINIMIZE = &HF020
Public Const SC_MAXIMIZE = &HF030
Public Const SC_CLOSE = 6
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000


Function No_x(hWnd As Long)
'desactive la croix rouge
Dim K As Long, hMenu As Long
hMenu = GetSystemMenu(hWnd, False)
K = DeleteMenu(hMenu, SC_CLOSE, MF_BYPOSITION)

End Function


Function No_Max(hWnd As Long)
'desactive le bouton maximiser
Dim hMenu As Long, K As Long

hMenu = GetSystemMenu(hWnd, False)
K = DeleteMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
K = GetWindowlong(hWnd, GWL_STYLE)
K = K Xor WS_MAXIMIZEBOX
SetWindowlong hWnd, GWL_STYLE, K

End Function


dans ma form mdi

Private Sub mdiForm_Load()
'Fhwnd = Me.hwnd
No_x (Me.hWnd)
No_Max (Me.hWnd)

With Me

.Width = 12000
.Height = 10000
End With
End Sub


la function No_X fonctionne tres bien
la function No_Max aucun changement

ou peut etre l'erreur

merci d'avance
gerard

1 réponse

Avatar
Jacques93
Bonjour gérard,
gérard a écrit :
bonjour


les declaration sont faites dans le module

Public Declare Function DeleteMenu Lib "user32" (ByVal hMenu As Long, ByVal
nPosition As Long, ByVal wFlags As Long) As Long
Public Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long,
ByVal bRevert As Long) As Long

Public Declare Function GetWindowlong Lib "user32" Alias "GetWindowLongA"
(ByVal hWnd As Long, nIndex As Long) As Long
Public Declare Function SetWindowlong Lib "user32" Alias "SetWindowLongA"
(ByVal hWnd As Long, nIndex As Long, ByVal dwNewLong As Long) As Long

Public Const GWL_STYLE = (-16)
Public Const MF_BYCOMMAND = &H0&
Public Const MF_BYPOSITION = &H400
Public Const SC_MINIMIZE = &HF020
Public Const SC_MAXIMIZE = &HF030
Public Const SC_CLOSE = 6
Public Const WS_MAXIMIZEBOX = &H10000
Public Const WS_MINIMIZEBOX = &H20000


Function No_x(hWnd As Long)
'desactive la croix rouge
Dim K As Long, hMenu As Long
hMenu = GetSystemMenu(hWnd, False)
K = DeleteMenu(hMenu, SC_CLOSE, MF_BYPOSITION)

End Function


Function No_Max(hWnd As Long)
'desactive le bouton maximiser
Dim hMenu As Long, K As Long

hMenu = GetSystemMenu(hWnd, False)
K = DeleteMenu(hMenu, SC_MAXIMIZE, MF_BYCOMMAND)
K = GetWindowlong(hWnd, GWL_STYLE)
K = K Xor WS_MAXIMIZEBOX
SetWindowlong hWnd, GWL_STYLE, K

End Function


dans ma form mdi

Private Sub mdiForm_Load()
'Fhwnd = Me.hwnd
No_x (Me.hWnd)
No_Max (Me.hWnd)

With Me

.Width = 12000
.Height = 10000
End With
End Sub


la function No_X fonctionne tres bien
la function No_Max aucun changement

ou peut etre l'erreur




Il faut que le paramètre nIndex des APIs 'GetWindowLong et SetWindowLong
soit passé ByVal :

Public Declare Function GetWindowlong Lib "user32" Alias _
"GetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long) As Long
Public Declare Function SetWindowlong Lib "user32" Alias _
"SetWindowLongA" (ByVal hWnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

sinon la ligne :

K = GetWindowlong(hWnd, GWL_STYLE)

renvoie 0 dans K, et si tu regardes Err.LastDllError tu constateras une
erreur 1413 : ERROR_INVALID_INDEX

Ensuite pour désactiver le bit correspondant à WS_MAXIMIZEBOX, remplaces
la ligne :

K = K Xor WS_MAXIMIZEBOX

par

K = K And Not (WS_MAXIMIZEBOX)

--
Cordialement,

Jacques.