Afficher un userform en plein écran et centré sur l'écran

nanie12 Messages postés 114 Date d'inscription vendredi 9 avril 2010 Statut Membre Dernière intervention 16 août 2011 - 10 mai 2010 à 16:32
nanie12 Messages postés 114 Date d'inscription vendredi 9 avril 2010 Statut Membre Dernière intervention 16 août 2011 - 11 mai 2010 à 11:15
Bonjour
je voudrai que mon userform s'affiche en plein écran et que celui-ci soit centré
malheureusement cela ne marche pas, l'userform est plein écran mais n'est pas centré.
voici ce que j'ai fait, merci de me dire ce que vous en pensez
Private Sub UserForm_Initialize()
  'affichage plein ecran
With UserForm9
.StartUpPosition = 1
.Width = Application.Width
.Height = Application.Height
.Left = 0
.Top = 0
End With
end sub


cordialement
nanie

8 réponses

cs_Le Pivert Messages postés 7903 Date d'inscription jeudi 13 septembre 2007 Statut Contributeur Dernière intervention 11 mars 2024 137
10 mai 2010 à 17:05
Bonjour,
Mettre dans l'UserForm:
' déclaration
Private Declare Function GetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLongA Lib "user32" _
(ByVal hwnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long
Private Declare Function FindWindowA Lib "user32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Sub UserForm_Initialize()
'Maximise et minimise
Dim hwnd As Long
hwnd = FindWindowA(vbNullString, Me.Caption)
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) Or &H10000 'maximise
SetWindowLongA hwnd, -16, GetWindowLongA(hwnd, -16) Or &H20000 'minimise
End Sub
@+
0
Rejoignez-nous