1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| Option Explicit
Declare Function fwa Lib "User32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function SetWindowLong Lib "User32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Declare Function GetWindowLong Lib "User32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Dim handle As Long, topframe As Long, leftframe As Long, heightme As Long, widthme As Long, X As Long
Dim ctrl As Object
Sub impression_frames(usf As Object, laframe As Object)
' ici on reprend l'idée de fring(invisibilité de tout les controls)
With usf
'rendre tous les contrôle du Userform1 invisibles
For Each ctrl In .Controls
ctrl.Visible = False
Next
'rendre la Frame2 visible
.Controls(laframe.Name).Visible = True
'rendre tous les contrôles de la Frame2 visibles
For X = 0 To .Controls(laframe.Name).Controls.Count - 1
.Controls(laframe.Name).Controls.Item(X).Visible = True
Next
End With
'on memorise la taille initial du userform
heightme = usf.Height
widthme = usf.Width
'on memorise la position initiale de la frame
topframe = usf.Controls(laframe.Name).Top
leftframe = usf.Controls(laframe.Name).Left
'on trouve le handle
handle = fwa(vbNullString, usf.Caption)
'on suprime la caption du userform
SetWindowLong handle, -16, GetWindowLong(handle, -16) And Not &HC00000 '*
'on deplace la frame a gauche et en haut
usf.Controls(laframe.Name).Top = 0
usf.Controls(laframe.Name).Left = 0
'on aplique les dimentions de la frame a lcelle de l'userfom
usf.Height = usf.Controls(laframe.Name).Height + 5
usf.Width = usf.Controls(laframe.Name).Width + 5
'on imprime l'userform
usf.printform
'on remet tout a l'initial
SetWindowLong handle, -16, GetWindowLong(handle, -16) Or &HC00000 '*
usf.Height = heightme
usf.Width = widthme
usf.Controls(laframe.Name).Top = topframe
usf.Controls(laframe.Name).Left = leftframe
For Each ctrl In usf.Controls
ctrl.Visible = True
Next
End Sub |
Partager