[VBA-E] Masquer Element Userform
a.dequidt
Messages postés
42
Date d'inscription
Statut
Membre
Dernière intervention
-
f894009 Messages postés 17277 Date d'inscription Statut Membre Dernière intervention -
f894009 Messages postés 17277 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Je cherche a supprimer la croix en haut a droite de la fenetre d'un userform...
Merci
Je cherche a supprimer la croix en haut a droite de la fenetre d'un userform...
Merci
A voir également:
- Emasquer
- É majuscule - Guide
- Masquer conversation whatsapp - Guide
- Comment masquer les amis sur facebook - Guide
- Comment appeler en masquer - Guide
- Comment savoir si quelqu'un a masquer sa story snapchat - Forum Snapchat
2 réponses
Si, c'est possible avec les APIs de Windows.
ATTENTION NE PAS OUBLIER D'AVOIR UN BOUTON POUR FERMER.........!
---------------------------- module 1 pour Auto_open -----------------------------------
'Pour éviter que les utilisateurs ne ferment un userform
'A placer au début du module
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
Sub auto_open()
UserForm1.Show (modal)
End Sub
----------------------------------------------------
----------------- Module API_Sup_Croix -----------------------------
'Suppression Croix X userform a l'initialisation
'-----------------------------------------------
Sub SupprimerFermeture(Name_Userform As String)
Dim hWnd As Long
hWnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _
"X", "D") & "Frame", Name_Userform)
SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) And &HFFF7FFFF
End Sub
-------------------------------------------------------------
'Dans chaque code de userform mettre :
Private Sub UserForm_Initialize()
Call SupprimerFermeture(Me.Caption)
'... autres instructions d'initialisation
End Sub
Private Sub CommandButton1_Click()
End
End Sub
ATTENTION NE PAS OUBLIER D'AVOIR UN BOUTON POUR FERMER.........!
---------------------------- module 1 pour Auto_open -----------------------------------
'Pour éviter que les utilisateurs ne ferment un userform
'A placer au début du module
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
Sub auto_open()
UserForm1.Show (modal)
End Sub
----------------------------------------------------
----------------- Module API_Sup_Croix -----------------------------
'Suppression Croix X userform a l'initialisation
'-----------------------------------------------
Sub SupprimerFermeture(Name_Userform As String)
Dim hWnd As Long
hWnd = FindWindowA("Thunder" & IIf(Application.Version Like "8*", _
"X", "D") & "Frame", Name_Userform)
SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) And &HFFF7FFFF
End Sub
-------------------------------------------------------------
'Dans chaque code de userform mettre :
Private Sub UserForm_Initialize()
Call SupprimerFermeture(Me.Caption)
'... autres instructions d'initialisation
End Sub
Private Sub CommandButton1_Click()
End
End Sub
Bonjour a.dequidt,
A ma connaissance ce n'est pas possible.
Par contre tu peux inhiber la croix de fermeture du formulaire en complétant l'événement 'QueryClose' comme suit :
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub
Tu peux même y ajouter un message d'avertissement :
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
MsgBox "Pour fermer ce formulaire, utilisez le bouton Fermer !",vbOKOnly+vbInformation
Cancel = True
End If
End Sub
Cordialement.
A ma connaissance ce n'est pas possible.
Par contre tu peux inhiber la croix de fermeture du formulaire en complétant l'événement 'QueryClose' comme suit :
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then Cancel = True
End Sub
Tu peux même y ajouter un message d'avertissement :
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
If CloseMode = 0 Then
MsgBox "Pour fermer ce formulaire, utilisez le bouton Fermer !",vbOKOnly+vbInformation
Cancel = True
End If
End Sub
Cordialement.