SuperNoizo
Messages postés23Date d'inscriptiondimanche 23 juin 2002StatutMembreDernière intervention30 janvier 2005
-
23 juin 2002 à 16:36
SuperNoizo
Messages postés23Date d'inscriptiondimanche 23 juin 2002StatutMembreDernière intervention30 janvier 2005
-
24 juin 2002 à 18:50
Boujour à tous,
Je cherche un API qui me permetterais de mettre en gris la croix en haut à droite comme dans une boîte de message(msgbox).
Merci
Declare Function DeleteMenu Lib "user32" Alias "DeleteMenu" ( _
ByVal hMenu As Long, _
ByVal nPosition As Long, _
ByVal wFlags As Long) As Long
Versions :
. Windows 95/98 : Oui
. Windows NT : A partir de 3.1
. Windows 2000/XP : Oui
Description :
Permet de supprimer un élément de menu.
hMenu est le handle du menu à manipuler.
nPosition est la position du menu (ou sous-menu) qui sera supprimé.
wFlags est la méthode de repérage utilisée : MF_BYCOMMAND ou MF_BYPOSITION.
Exemple d'utilisation :
' Origine : fred - chapeaux.ronds@wanadoo.fr
' Le code qui suis permet de désactiver les boutons "X", "min", "max".
' Créer un nouveau projet vb et coller le code suivant dans
' "déclaration" puis essayer les trois boutons les uns après les autres
' (pour cela enlever l'apostrophe devant "no_min" et "no_max").
Option Explicit
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 Sub no_x()
' Désactiver X
Dim hMenu As Long, k As Long
hMenu = GetSystemMenu(hwnd, False)
k = DeleteMenu(hMenu, SC_CLOSE, MF_BYPOSITION)
End Sub
Private Sub no_min()
' Désactiver 'minimiser'
Dim hMenu As Long, k As Long
hMenu = GetSystemMenu(hwnd, False)
k = DeleteMenu(hMenu, SC_MINIMIZE, MF_BYCOMMAND)
k = GetWindowLong(hwnd, GWL_STYLE)
k = k Xor WS_MINIMIZEBOX
SetWindowLong hwnd, GWL_STYLE, k
End Sub
Private Sub no_max()
' Désactiver '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 Sub
Private Sub Form_Load()
no_x
' no_min
' no_max
End Sub