Bonjour,
dans un TGraphicControl je trace une ligne tout en haut (position 0,0). Si la ligne fait 1 ou 2 pixels, pas de problème mais s'il fait 3 ou plus, tout ne se trace pas.
Ainsi pour 5 pixel, on que 2 pixels.
J'en déduis donc que lorsqu'il trace le trait il met 2 pixel d'un côté, et 3 de l'autre.
Comment faire alors pour avoir bien 5 pixels sur les bordures ?
Voici mon code :
Merci
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 { 1 - Dessiner le rectangle } Canvas.Brush.Style := bsSolid ; Canvas.Brush.Color := FBackColor ; Canvas.Pen.Style := psSolid ; Canvas.Pen.Color := FBackColor ; Rect.Top := FBorderSize ; Rect.Left := FBorderSize ; Rect.Right := Self.Width - FBorderSize ; Rect.Bottom := Self.Height - FBorderSize ; { On soustrait le texte du rectangle } if FTextPosition in [tpBottomCenter, tpBottomLeft, tpBottomRight] then begin Rect.Bottom := Rect.Bottom - TextHeight ; end ; Canvas.FillRect(Rect); Canvas.Pen.Style := psSolid ; Canvas.Pen.Color := FBorderColor ; Canvas.Pen.Width := FBorderSize ; Canvas.MoveTo(0,0); Canvas.LineTo(Self.Width - 1, 0); if FTextPosition in [tpBottomCenter, tpBottomLeft, tpBottomRight] then begin Canvas.LineTo(Self.Width - 1, Self.Height - 1 - TextHeight) ; Canvas.LineTo(0, Self.Height - 1 - TextHeight) ; end else begin Canvas.LineTo(Self.Width - 1, Self.Height - 1) ; Canvas.LineTo(0, Self.Height - 1) ; end ; Canvas.LineTo(0, 0);
Partager