solution à base de Panels (3)
rapidement , avant de partir en ville , en xe4 / vcl
Code:
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
| object Form1: TForm1
Left = 0
Top = 0
Caption = 'Form1'
ClientHeight = 406
ClientWidth = 618
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object Panel1: TPanel
Left = 0
Top = 0
Width = 177
Height = 406
Align = alLeft
Caption = 'Panel1'
TabOrder = 0
object Button1: TButton
AlignWithMargins = True
Left = 4
Top = 4
Width = 169
Height = 25
Align = alTop
Caption = 'Button1'
TabOrder = 0
ExplicitLeft = 32
ExplicitTop = 16
ExplicitWidth = 121
end
object ListBox1: TListBox
AlignWithMargins = True
Left = 4
Top = 35
Width = 169
Height = 367
AutoComplete = False
Align = alClient
ItemHeight = 13
TabOrder = 1
ExplicitLeft = 32
ExplicitTop = 55
ExplicitWidth = 121
ExplicitHeight = 314
end
end
object Panel2: TPanel
Left = 441
Top = 0
Width = 177
Height = 406
Align = alRight
Caption = 'Panel1'
TabOrder = 1
ExplicitLeft = 8
object Button2: TButton
AlignWithMargins = True
Left = 4
Top = 4
Width = 169
Height = 25
Align = alTop
Caption = 'Button1'
TabOrder = 0
end
object ListBox2: TListBox
AlignWithMargins = True
Left = 4
Top = 35
Width = 169
Height = 367
AutoComplete = False
Align = alClient
ItemHeight = 13
TabOrder = 1
end
end
object Panel3: TPanel
Left = 177
Top = 0
Width = 264
Height = 406
Align = alClient
Caption = 'Panel3'
TabOrder = 2
ExplicitLeft = 224
ExplicitTop = 200
ExplicitWidth = 185
ExplicitHeight = 41
DesignSize = (
264
406)
object StringGrid1: TStringGrid
AlignWithMargins = True
Left = 8
Top = 8
Width = 256
Height = 185
Anchors = [akLeft, akTop, akRight, akBottom]
TabOrder = 0
end
end
end |
Marges : une question de calcul élémentaire ?
Une petite pause. J'en profite pour évoquer un problème idiot, qui n'a pas pour autant ralentit mon analyse du problème.
Le projet (vite fait) mais bien utile de Serge : 3 panels principaux. Je lis le dfm du Panel1 et calcule la position "automatique" du ListBox.
J'ouvre le dfm. Les AlignWithMargins sont activées avec des margins de 3 par défaut. Mais le compte n'est jamais juste. Je suis incapable de calculer les marges enfin d'obtenir les nombres précisés dans le dfm notamment le ListBox1.Top = 35. C'est un calcul effectué par l'IDE et je n'obtiens pas 35 de manière raisonnée, pas plus en tenant compte des BevelWidth -qui d'ailleurs ne semblent pas intervenir dans le sens de la hauteur*- que d'une aucune autre manière.
*Sur un exemple plus simple utilisé par soucis de compréhension, j'ai cette interprétation faute de mieux. Une Form sans margins et un TPanel alClient, AlignWithMargins désactivé.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| object Form2: TForm2
Left = 0
Top = 0
Margins.Left = 0
Margins.Top = 0
Margins.Right = 0
Margins.Bottom = 0
ClientHeight = 320
ClientWidth = 186
Color = clBtnFace
object Panel1: TPanel
Left = 0
Top = 0
Width = 185
Height = 320
Margins.Left = 0
Margins.Top = 0
Margins.Right = 0
Margins.Bottom = 0
Align = alLeft
ExplicitHeight = 41
end
end |
AlignWithMargins n'est pas activé et de toute façon j'ai défini les Margins.xx à 0.
Je prends note également du fait que BevelWidth est forcément supérieur strictement à 0 (1 par défaut).
Alors je lis :
Form 2 :
- ClientHeight = 320
- ClientWidth = 186
Le Panel qu'elle contient est alClient... donc occupe normalement toute la surface. On peut imaginer un décalage de 2, bord à bord à touche touche donc -1 à gauche, -1 à droite... ou on peut envisager un "effet de bord BevelWidth" sur la largeur uniquement (d'où le nom), ou une superposition totale.
Code:
1 2 3
|
Width = 185
Height = 320 |
La perte de 1 dans la largeur est à mon sens assimilable à la 2ème solution. Mais je ne vois rien dans le sens de la hauteur qui expliquerait le 35 du dfm.