IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage Delphi Discussion :

Color, Font, Size


Sujet :

Langage Delphi

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    92
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 92
    Points : 61
    Points
    61
    Par défaut Color, Font, Size
    Suivant une instruction, je changes la couleur, taille, fonte de certains edit, label, ...
    Pour cla, je fais :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    with Edit4 do
          Begin
              Font.Name:=FontName;
              Font.Color:=FontColor;
              Font.Size:=FontSize;
          end;
      with Label11 do
          Begin
              Font.Name:=FontName;
              Font.Color:=FontColor;
              Font.Size:=FontSize;
          end;
    J'en ai pas mal comme ca ... Connaissez vous une instruction du style :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    With Font.Name:=FontName and Font.Color:=FontColor and Font.Size:=FontSize do
    Begin
          Edit1 ....
          Label1 ....
    End;

  2. #2
    Rédacteur
    Avatar de Pedro
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    5 411
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 5 411
    Points : 8 078
    Points
    8 078
    Par défaut
    Salut
    Tu as la possibilité, déjà, de mettre ton code entre les balises code pour que ce soit plus lisible ensuite, tu peux faire:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
    var i:integer;
         t:TControl; 
    for i:=0 to ControlsCOunt-1 do
    if (Controls[i]=Edit4) or (Controls[i]=Label1) or ... then
    with Controls[i].Font do
    begin
      Name:=FontName;
      Color:=FontColor;
      Size:=FontSize;
    end;
    C'est une possibilité mais il y en surement d'autres
    Pedro
    Aucune réponse aux sollicitations techniques par MP

    Faut pas attendre d'en avoir besoin pour s'en servir... (Lucien Stéphane)

    Les pages Source C'est bon. Mangez-en!
    Le défi Delphi
    Règles du forum - FAQ Delphi - Pensez au chtit
    Aéroclub Bastia Saint-Exupéry

  3. #3
    Membre expert
    Avatar de TicTacToe
    Inscrit en
    Septembre 2005
    Messages
    1 940
    Détails du profil
    Informations personnelles :
    Âge : 51

    Informations forums :
    Inscription : Septembre 2005
    Messages : 1 940
    Points : 3 575
    Points
    3 575
    Par défaut
    Toujours en parcourant des composants,
    il y a effectivement d'autres méthodes
    A chacun de trouver la sienne

    voir
    http://www.developpez.net/forums/vie...light=#2582700
    Section Delphi
    La mine d'or: La FAQ, les Sources

    Un développement compliqué paraitra simple pour l'utilisateur, frustrant non ?
    Notre revanche ? l'inverse est aussi vrai ;-)

  4. #4
    Membre expert
    Avatar de LadyWasky
    Femme Profil pro
    Inscrit en
    Juin 2004
    Messages
    2 932
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Âge : 53
    Localisation : France, Hauts de Seine (Île de France)

    Informations forums :
    Inscription : Juin 2004
    Messages : 2 932
    Points : 3 565
    Points
    3 565
    Par défaut
    Salut,
    Oui, tu crées une procedure avec en paramètre un TControl :

    Je te propose 4 possibilités :
    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
    38
    39
    40
    41
     
    //Important : ligne à ne pas oublier ! (à mettre juste avant ta procedure, ou dans la partie interface de ton unité)
    type TPublicControl=class(TControl);
    //
    procedure InitFont1(AControlArray:array of TControl;FontName:string;FontColor:TColor;FontSize:Integer);
    var i:Integer;
    begin
      if SizeOf(AControlArray)=0 then Exit; //si on a pas fourni d'éléments dans le tableau
      for i:=Low(AControlArray) to High(AControlArray) do
      with TPublicControl(AControlArray[i]).Font do
      begin
        Name:=FontName;
        Color:=FontColor;
        Size:=FontSize;
      end;
    end;
     
    procedure InitFont2(AControlArray:array of TControl;AFont:TFont);
    var i:Integer;
    begin
      if SizeOf(AControlArray)=0 then Exit;
      for i:=Low(AControlArray) to High(AControlArray) do
      TPublicControl(AControlArray[i]).Font:=AFont;
    end;
     
    procedure InitFont3(AControl:TControl;FontName:string;FontColor:TColor;FontSize:Integer);
    var i:Integer;
    begin
      with TPublicControl(AControl).Font do
      begin
        Name:=FontName;
        Color:=FontColor;
        Size:=FontSize;
      end;
    end;
     
    procedure InitFont4(AControl:TControl;AFont:TFont);
    var i:Integer;
    begin
      TPublicControl(AControl).Font:=AFont;
    end;
    Que tu utilises ainsi :

    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
    //Edit1 est un TEdit;
      //Label1 est un TLabel;
      //GroupBox1 est un TGroupBox;
      //Memo1 est un TMemo;
      //Button1 est un TButton;
     
      ...
     
      //Plusieurs contrôles à la fois
      InitFont1([Edit1,Label1,GroupBox1,Memo1,Button1],'Arial',clRed,12);
     
      //Pareil mais en utilisant un paraètre TFont
      if FontDialog1.Execute then
      InitFont2([Edit1,Label1,GroupBox1,Memo1,Button1],FontDialog1.Font);
     
      //La même chose que ci dessus mais avec un seul contrôle à la fois
      InitFont3(Edit1,'Arial',clRed,12);
      if FontDialog1.Execute then InitFont4(Label1,FontDialog1.Font);
    Bon dev
    Bidouilleuse Delphi

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Décembre 2005
    Messages
    92
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2005
    Messages : 92
    Points : 61
    Points
    61
    Par défaut
    Merci pour votre aide !!

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. affichage: block color font-size
    Par omelhor dans le forum Mise en page CSS
    Réponses: 2
    Dernier message: 05/07/2010, 15h47
  2. Probleme de font-size
    Par Yoshidu62 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 2
    Dernier message: 20/06/2006, 12h00
  3. DIV Font Size
    Par MxPx_23 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 5
    Dernier message: 30/05/2006, 21h12
  4. le font-size sur ie et fire fox
    Par henri68 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 6
    Dernier message: 27/05/2006, 17h35
  5. [font.size] Comment descendre en dessous de 8 ?
    Par Dry dans le forum Composants VCL
    Réponses: 3
    Dernier message: 23/04/2004, 16h01

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo