Function dpi()
With ActiveWindow.ActivePane
dpi = Round(((.PointsToScreenPixelsY(Cells.Height) - ActiveWindow.ActivePane.PointsToScreenPixelsY(0)) / Cells.Height) * 72)
End With
End Function
Sub test()
MsgBox dpi
End Sub
Ça je savais, c'est le Page qui les a mais celui là n'a aucune propriété de positionnement Left, Top, Width ni Height.j'ai testé aussi ecx ecy en prenant en compte le parent a chaque fois, pour multipage j'ai une erreur il n'a pas le insideheight
Public Sub Posit(ByVal Obj As Object, Optional ByVal X As Double, Optional ByVal Y As Double)
Rem. ——— Vous pouvez au préalable positionner l'UserForm par rapport à quelque chose.
' Obj: Ce par rapport à quoi vous voulez le positionner. X et Y indiqueront comment :
' X: -1: Collé au coté gauche, 0: Centré horizontalement, 1: Collé au coté droit.
' Y: -1: Collé au bord supérieur, 0: Centré verticalement, 1: Collé juste en dessous.
' D'autres valeurs entraineront un recouvrement partiel ou un certain éloignement.
' Mais rien ne vous empêche de rectifier encore ensuite la propriété Left ou Top
' de l'UFmCalend pour ajouter un interstice en points au bord de l'objet. Mais toujours
' avant le Show, donc avant utilisation de la méthode Saisie.
' X et Y sont facultatifs et assumés = 0. Il est donc centré sur l'objet Obj si non précisés.
Dim Lft As Double, Rgt As Double, Top As Double, Bot As Double, U As Object, _
UInsWidth As Single, UInsHeight As Single, K As Double, Zom As Double
If TypeOf Obj Is MSForms.Control Then
Lft = Obj.Left: Top = Obj.Top: Set U = Obj.Parent ' Normalement Page, Frame ou UserForm
Do: UInsWidth = U.InsideWidth: UInsHeight = U.InsideHeight ' Le Page en est pourvu, mais pas le Multipage.
If TypeOf U Is MSForms.Page Then Set U = U.Parent ' On prend le Multipage, car le Page n'a aucune propriété de Positionnement.
K = (U.Width - UInsWidth) / 2
Lft = Lft + U.Left + K: Top = Top + U.Top + U.Height - K - UInsHeight
If Not (TypeOf U Is MSForms.Frame Or TypeOf U Is MSForms.MultiPage) Then Exit Do
Set U = U.Parent: Loop
Rgt = Lft + Obj.Width: Bot = Top + Obj.Height
Else
Zom = ActiveWindow.Zoom / 100
K = GetDeviceCaps(GetDC(0), 88) / 72
Lft = ActiveWindow.PointsToScreenPixelsX(Obj.Left * K * Zom) / K
Rgt = ActiveWindow.PointsToScreenPixelsX((Obj.Left + Obj.Width) * K * Zom) / K
K = GetDeviceCaps(GetDC(0), 90) / 72
Top = ActiveWindow.PointsToScreenPixelsY(Obj.Top * K * Zom) / K
Bot = ActiveWindow.PointsToScreenPixelsY((Obj.Top + Obj.Height) * K * Zom) / K
End If
Me.Left = (X * (Rgt - Lft + Me.Width + 6) + Lft + Rgt - Me.Width - 6) / 2 + 3
Me.Top = (Y * (Bot - Top + Me.Height + 6) + Top + Bot - Me.Height - 6) / 2 + 3
End Sub
Private Sub UserForm_Click()
MsgBox MultiPage1.Height - MultiPage1.InsideHeight
End Sub
'dranreb
Dim Lft As Double, Rgt As Double, Top As Double, Bot As Double, U As Object, _
UInsWidth As Single, UInsHeight As Single, K As Double
' If TypeOf Obj Is MSForms.Control Then
Lft = Obj.Left: Top = Obj.Top: Set U = Obj.Parent ' Normalement Page, Frame ou UserForm
Do: UInsWidth = U.InsideWidth: UInsHeight = U.InsideHeight ' Le Page en est pourvu, mais pas le Multipage.
If TypeOf U Is MSForms.Page Then Set U = U.Parent ' On prend le Multipage, car le Page n'a aucune propriété de Positionnement.
K = (U.Width - UInsWidth) / 2
Lft = Lft + U.Left + K: Top = Top + U.Top + U.Height - K - UInsHeight
If Not (TypeOf U Is MSForms.Frame Or TypeOf U Is MSForms.MultiPage) Then Exit Do
Set U = U.Parent: Loop
'Rgt = Lft + Obj.Width: Bot = Top + Obj.Height
X = Lft + Obj.Width: Y = Top + 3 '< rajout perso
' End If
' ROUTINE STD INIT POSITION X/Y OBJET SUR USERFORM.ACTIVATE
'----------------------------------------------------------------
Public Sub UserformInitPosObjAppelant(Obj As Object, X@, Y@) 'X/Y en retour
Dim Lft As Double, Rgt As Double, Top As Double, Bot As Double, U As Object, _
UInsWidth As Single, UInsHeight As Single, K As Double
Lft = Obj.Left: Top = Obj.Top: Set U = Obj.Parent ' Normalement Page, Frame ou UserForm
Do: UInsWidth = U.InsideWidth: UInsHeight = U.InsideHeight ' Le Page en est pourvu, mais pas le Multipage.
If TypeOf U Is MSForms.Page Then Set U = U.Parent ' On prend le Multipage, car le Page n'a aucune propriété de Positionnement.
K = (U.Width - UInsWidth) / 2
Lft = Lft + U.Left + K: Top = Top + U.Top + U.Height - K - UInsHeight
If Not (TypeOf U Is MSForms.Frame Or TypeOf U Is MSForms.MultiPage) Then Exit Do '>
Set U = U.Parent
Loop
'Rgt = Lft + Obj.Width: Bot = Top + Obj.Height
X = Lft + Obj.Width: Y = Top + 3 '< rajout perso
End Sub
Vous n'avez apparemment toujours pas compris qu'il faut faire le calcul avec le Height du Multipage et le InsideHeight du Page, donc soit garder momentanément les deux objets sous le coude, comme j'avais fait dans ma 1ère mouture, soit noter les InsideWidth et InsideHeight du Page dans des variables avant de remonter au MultiPage, vu que lui ne les a plus.vos méthodes ne fonctionnent pas je viens de tester