' Envoyer un message à une fenêtre
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_CLOSE = &H10
' Change le texte de la fenêtre
Public Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String) As Long
' Pour activer une fenêtre avec son handle
Public Declare Function EnableWindow Lib "user32" (ByVal hWnd As Long, ByVal fEnable As Long) As Long
' Manipuler les menus d'une fenêtre
Public Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Public Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Public Const MF_BYPOSITION = &H400&
Public Const MF_REMOVE = &H1000&
' Change le texte d'une fenêtre
Public Function RenameWindow(ByVal hWnd As Long, ByVal Caption As String)
SetWindowText hWnd, Caption
End Function
' Activer une fenêtre
Public Function EnableWindow(ByVal hWnd As Long)
EnableWindow hWnd, True
End Function
' Desactiver une fenêtre
Public Function DisableWindow(ByVal hWnd As Long)
EnableWindow hWnd, False
End Function
' Ferme une fenêtre
Public Function CloseWindow(hWnd As Long)
SendMessage hWnd, WM_CLOSE, 0, 0
End Function
' Permet d'activer la croix "Fermer" du menu système d'une fenêtre lorsqu'elle était grisée
Public Function EnableCloseButton(ByVal hWnd As Long)
' ici je dégrise grâce à true qui remet le menu à zéro
GetSystemMenu hWnd, True
DrawMenuBar hWnd
End Function
' Désactive la croix fermer
Public Function DisableCloseButton(ByVal hWnd As Long)
Dim hMenu As Long
Dim nCount As Long
hMenu = GetSystemMenu(hWnd, 0)
nCount = GetMenuItemCount(hMenu)
Call RemoveMenu(hMenu, nCount - 1, MF_REMOVE Or MF_BYPOSITION)
Call RemoveMenu(hMenu, nCount - 2, MF_REMOVE Or MF_BYPOSITION)
DrawMenuBar hWnd
End Function
Seul les admins et l'auteur du code lui même peuvent modifier ce code.