Supprimer / masquer bouton supprimer userform

  • Initiateur de la discussion Initiateur de la discussion neoboy
  • Date de début Date de début

Boostez vos compétences Excel avec notre communauté !

Rejoignez Excel Downloads, le rendez-vous des passionnés où l'entraide fait la force. Apprenez, échangez, progressez – et tout ça gratuitement ! 👉 Inscrivez-vous maintenant !

N

neoboy

Guest
Bonsoir,


Y a t-il moyen de supprimer / masquer la croix rouge qui permet de fermer un userform ?


Merdi .
 
Re : Supprimer / masquer bouton supprimer userform

Bonsoir, une possibilité:

Dans un module courant:

Code:
Public Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

Const GWL_STYLE = (-16)
Const WS_CAPTION = &HC00000
Const SWP_FRAMECHANGED = &H20

Public Declare Function FindWindowA Lib "user32" _
        (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
        
Public Declare Function GetWindowRect Lib "user32" _
        (ByVal hwnd As Long, lpRect As RECT) As Long
        
Public Declare Function GetWindowLong Lib "user32" Alias _
        "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long

Public Declare Function SetWindowLong Lib "user32" Alias _
        "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, _
        ByVal dwNewLong As Long) As Long

Public Declare Function SetWindowPos Lib "user32" _
        (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, _
        ByVal y As Long, ByVal cx As Long, ByVal cy As Long, _
        ByVal wFlags As Long) As Long

Sub VOIR_BANDE_BLEUE(stCaption As String, pbVisible As Boolean)
Dim vrWin As RECT
Dim style As Long
Dim lHwnd As Long
    lHwnd = FindWindowA(vbNullString, stCaption)
    GetWindowRect lHwnd, vrWin
    style = GetWindowLong(lHwnd, GWL_STYLE)
    If pbVisible Then
        SetWindowLong lHwnd, GWL_STYLE, style Or WS_CAPTION
    Else
        SetWindowLong lHwnd, GWL_STYLE, style And Not WS_CAPTION
    End If
    SetWindowPos lHwnd, 0, vrWin.Left, vrWin.Top, vrWin.Right - vrWin.Left, _
            vrWin.Bottom - vrWin.Top, SWP_FRAMECHANGED
End Sub

Dans l'UserForm:

Code:
Private Sub UserForm_Initialize()
   VOIR_BANDE_BLEUE Me.Caption, False
End Sub

Et là tu ne vois plus la Bande Bleue.

Mais il ne faudra pas oublier de créer un bouton de fermeture.

Avec: "Unload Me" pour fermer l'USF.

Sinon: Alt + F4

Au plaisir

Yann
 
- Navigue sans publicité
- Accède à Cléa, notre assistante IA experte Excel... et pas que...
- Profite de fonctionnalités exclusives
Ton soutien permet à Excel Downloads de rester 100% gratuit et de continuer à rassembler les passionnés d'Excel.
Je deviens Supporter XLD
Assurez vous de marquer un message comme solution pour une meilleure transparence.

Discussions similaires

  • Question Question
Microsoft 365 bouton supprimer
Réponses
4
Affichages
228
  • Question Question
Microsoft 365 Personal.xlsb
Réponses
4
Affichages
756
  • Question Question
XL 2019 User Form
Réponses
9
Affichages
526
Retour