1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
Option Explicit
Private Const SC_CLOSE = &HF060&
Private Const MF_BYCOMMAND = &H0&
Declare Function GetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function FindWindowA Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Sub restaurer_croix_sys()
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) Or &H80000
End Sub
Sub supprimer_croix_sys()
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Application.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) And &HFFF7FFFF
End Sub
'faire appel a cette macro au moment que tu veux ca pour effet de bloquer l'action du bouton fermer de l'application
Sub bloque_la_croix()
Dim hSysMenu As Long
Dim handleapp As Long
handleapp = FindWindowA(vbNullString, Application.Caption)
If handleapp > 0 Then
hSysMenu = GetSystemMenu(handleapp, False)
RemoveMenu hSysMenu, SC_CLOSE, MF_BYCOMMAND
Else
MsgBox "Handle de " & Application.Caption & " Introuvable", vbCritical
End If |
Partager