Précédent   Forum du club des développeurs et IT Pro > Autres langages > Pascal > Lazarus
Lazarus Forum d'entraide sur Lazarus, l'EDI RAD multiplateforme basé sur Free Pascal
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 27/11/2012, 09h49   #1
ApproxDev
Nouveau Membre du Club
 
Homme Benjamin
Codeur
Inscription : août 2012
Messages : 37
Détails du profil
Informations personnelles :
Nom : Homme Benjamin
Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

Informations professionnelles :
Activité : Codeur

Informations forums :
Inscription : août 2012
Messages : 37
Points : 36
Points : 36
Par défaut Ancrage et programmation

Bonjour,

A partir de la vignette ci-dessous, comment traduit-on l'ancrage (rouge) en langage de programmation ?

Le Label1 est "inclus" dans Panel1 (Label1.Parent := Panel1)

Pour l'ancrage vert, le code suivant semble fonctionner
Code :
1
2
3
4
With Label1 do begin
     AnchorSideTop.Control:= Panel1;
     AnchorSideTop.Side:= asrCenter;
End;
D'une part, je n'arrive pas à aligner le bord droit du Label1 sur le bord droit du Panel1. Et d'autre part, je ne sais pas comment on "écrit" le décalage de 10.

Merci.
A+
Images attachées
Type de fichier : png Anchor.png (46,8 Ko, 13 affichages)
ApproxDev est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/11/2012, 13h28   #2
ApproxDev
Nouveau Membre du Club
 
Homme Benjamin
Codeur
Inscription : août 2012
Messages : 37
Détails du profil
Informations personnelles :
Nom : Homme Benjamin
Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

Informations professionnelles :
Activité : Codeur

Informations forums :
Inscription : août 2012
Messages : 37
Points : 36
Points : 36
La solution trouvée :
Code :
1
2
3
4
5
6
7
8
With Label1 do begin
      AnchorSideTop.Control:= Panel1;
      AnchorSideTop.Side:= asrCenter;
      AnchorSideRight.Control:= Panel1;
      AnchorSideRight.Side:= asrRight;
      BorderSpacing.Right:= 80;
      Anchors:= Anchors + [akTop, akRight];
End;
La ligne qui valide et exécute le réglage est Anchors:= Anchors + [akTop, akRight];
ApproxDev est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 27/11/2012, 18h13   #3
ApproxDev
Nouveau Membre du Club
 
Homme Benjamin
Codeur
Inscription : août 2012
Messages : 37
Détails du profil
Informations personnelles :
Nom : Homme Benjamin
Localisation : France, Alpes Maritimes (Provence Alpes Côte d'Azur)

Informations professionnelles :
Activité : Codeur

Informations forums :
Inscription : août 2012
Messages : 37
Points : 36
Points : 36
Par défaut Ancrage et programmation (suite)

Rebonjour,

je crois que j'en ai pas fini avec les ancrages.
Le code :
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
procedure TmyBitBtn.Anchoring;
begin
  if not FGlyph.Empty then
    with FImage do begin
      AnchorSideTop.Control:= Self;
      AnchorSideTop.Side   := asrCenter;
      if FGlyphPosition = aGlyphLeft then begin
        AnchorSideLeft.Control:= Self;
        AnchorSideLeft.Side   := asrLeft;
        BorderSpacing.Left    := FGlyphHorizSpace;
        Anchors := Anchors +[akTop, akLeft];
      end else begin
        AnchorSideRight.Control:= Self;
        AnchorSideRight.Side   := asrRight;
        BorderSpacing.Right:= FGlyphHorizSpace;
        Anchors := Anchors +[akTop, akRight] -[akLeft];
        {!! Par défaut akLeft et akTop sont sélectionnés donc -[akLeft]}
      end;
    end;
 
  with FLabel do begin
    Alignment := taCenter;
    Layout:= tlCenter;
    AnchorSideTop.Control    := Self;
    AnchorSideTop.Side       := asrTop;
    AnchorSideBottom.Control := Self;
    AnchorSideBottom.Side    := asrBottom;
    if FGlyphPosition = aGlyphLeft then begin
      AnchorSideRight.Control := Self;
      AnchorSideRight.Side    := asrRight;
      BorderSpacing.Right     := 0;
      AnchorSideLeft.Control  := Self;
      AnchorSideLeft.Side     := asrLeft;
      BorderSpacing.Left      := FGlyphHorizSpace +FImage.Width;
      // AnchorParallel(akLeft,0,FImage);
      Anchors := Anchors +[akTop, akBottom, akLeft, akRight];
    end else begin
      AnchorSideLeft.Control  := Self;
      AnchorSideLeft.Side     := asrLeft;
      BorderSpacing.Left      := 0;
      AnchorSideRight.Control := Self;
      AnchorSideRight.Side    := asrRight;
      BorderSpacing.Right     := FGlyphHorizSpace +FImage.Width;
      Anchors := Anchors +[akTop, akBottom, akLeft, akRight];
    end;
  end;
end;
L'objectif : placer FImage et FLabel l'un à côté de l'autre dans le TCustomControl qui est leur parent. Voir la vignette en bas...

Le problème : le code de la ligne 35.

Le contournement : les lignes 32 à 34.
Comment fait-on cela proprement ?

Merci.
Images attachées
Type de fichier : png Anchor02.png (15,6 Ko, 5 affichages)
ApproxDev est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 11h39.


 
 
 
 
Partenaires

Hébergement Web