[VBA-E] Masquer Element Userform
Fermé
a.dequidt
Messages postés
42
Date d'inscription
mardi 4 septembre 2007
Statut
Membre
Dernière intervention
23 octobre 2007
-
17 sept. 2007 à 10:20
f894009 Messages postés 17241 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 19 février 2025 - 25 nov. 2007 à 11:17
f894009 Messages postés 17241 Date d'inscription dimanche 25 novembre 2007 Statut Membre Dernière intervention 19 février 2025 - 25 nov. 2007 à 11:17
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:
- [VBA-E] Masquer Element Userform
- É - Guide
- Masquer conversation whatsapp - Guide
- Comment masquer les amis sur facebook - Guide
- Application pour masquer les applications - Guide
- Comment appeler en masquer - Guide
2 réponses
f894009
Messages postés
17241
Date d'inscription
dimanche 25 novembre 2007
Statut
Membre
Dernière intervention
19 février 2025
1 713
25 nov. 2007 à 11:17
25 nov. 2007 à 11:17
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
Papou93
Messages postés
146
Date d'inscription
mercredi 4 avril 2007
Statut
Membre
Dernière intervention
5 juin 2012
59
17 sept. 2007 à 20:46
17 sept. 2007 à 20:46
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.