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 :

Convertir la valeur dyLineSpacing en interligne


Sujet :

Langage Delphi

  1. #1
    Membre actif Avatar de XeGregory
    Homme Profil pro
    Passionné par la programmation
    Inscrit en
    Janvier 2017
    Messages
    313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Marne (Champagne Ardenne)

    Informations professionnelles :
    Activité : Passionné par la programmation
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Janvier 2017
    Messages : 313
    Points : 273
    Points
    273
    Par défaut Convertir la valeur dyLineSpacing en interligne
    Bonjour à tous

    A quoi correspond la valeur dyLineSpacing (Byte 0..255) ?
    Comment convertir la valeur dyLineSpacing en interligne exemple : 1,00 - 1,15 - 1,50 - 2,00 ?

    Nom : Capture.PNG
Affichages : 145
Taille : 13,5 Ko

    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
    procedure SetLineSpacing(RichEdit: TRichEdit; LineSpacing: Byte);
    var
      ParaFormat: ParaFormat2;
    begin
      FillChar(ParaFormat, SizeOf(ParaFormat), 0);
     
      with ParaFormat do
      begin
        cbSize := SizeOf(ParaFormat2);
        dwMask := PFM_LINESPACING;
        bLineSpacingRule := 5;
        dyLineSpacing := LineSpacing;
      end;
      SendMessage(RichEdit.Handle, EM_SETPARAFORMAT, 0, Longint(@ParaFormat));
    end;
     
    function GetLineSpacing(RichEdit: TRichEdit): Byte;
    var
      ParaFormat: PARAFORMAT2;
    begin
      FillChar(ParaFormat, SizeOf(ParaFormat), 0);
      ParaFormat.cbSize := SizeOf(PARAFORMAT2);
      SendMessage(RichEdit.Handle, EM_GETPARAFORMAT, 0, Longint(@ParaFormat));
      Result := ParaFormat.dyLineSpacing;
    end;
    https://learn.microsoft.com/fr-fr/wi...it-paraformat2

    Merci

  2. #2
    Membre actif Avatar de XeGregory
    Homme Profil pro
    Passionné par la programmation
    Inscrit en
    Janvier 2017
    Messages
    313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Marne (Champagne Ardenne)

    Informations professionnelles :
    Activité : Passionné par la programmation
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Janvier 2017
    Messages : 313
    Points : 273
    Points
    273
    Par défaut
    La valeur de dyLineSpacing / 20 est l’espacement, en lignes, d’une ligne à l’autre. Ainsi, la définition de dyLineSpacing sur 20 produit du texte interligne simple, 40 est interligne double, 60 est interligne triple, et ainsi de suite.
    20 = 1,00

  3. #3
    Expert éminent sénior
    Avatar de Paul TOTH
    Homme Profil pro
    Freelance
    Inscrit en
    Novembre 2002
    Messages
    8 964
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 55
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Freelance
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Novembre 2002
    Messages : 8 964
    Points : 28 457
    Points
    28 457
    Par défaut
    ben

    si bLineSpacingRule = 0 Espacement unique. Le membre dyLineSpacing est ignoré. (1,00)
    si bLineSpacingRule = 1 Un espacement et demi. Le membre dyLineSpacing est ignoré. (1,50)
    si bLineSpacingRule = 2 Espacement double. Le membre dyLineSpacing est ignoré. (2,00)
    si bLineSpacingRule = 3 ou 4 Le membre dyLineSpacing spécifie l’espacement d’une ligne à la suivante, en twips.
    si bLineSpacingRule = 5 La valeur de dyLineSpacing / 20 est l’espacement, en lignes, d’une ligne à l’autre.

    donc si tu veux 1,15, il faut la règle 5 et multiplier par 20 donc dyLineSpacing = 23, puisque 23/20 = 1.15

    enfin c'est comme ça que je le comprend

  4. #4
    Expert confirmé
    Avatar de anapurna
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Mai 2002
    Messages
    3 435
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : Arts - Culture

    Informations forums :
    Inscription : Mai 2002
    Messages : 3 435
    Points : 5 848
    Points
    5 848
    Par défaut
    salut


    selon le choix du rule que tu fournis les espacement différent

    5 c'est un effet additionel
    3 est soustrayant
    4 est la valeur exact
    il se rapporte toujours au format precedent

    essai avec cette fonction et dis nous si tu vois une difference

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
     
    Procedure  setLineFormat(RE : TRichEdit;rule : Byte;space : Integer)
    Begin
      FillChar(ParaFormat, SizeOf(ParaFormat), 0);       
      SendMessage(RE.Handle, EM_GETPARAFORMAT, 0, LParam(@ParaFormat));
      with ParaFormat do
      begin
        cbSize := SizeOf(ParaFormat2);
    	dwMask = PFM_LINESPACING;
        bLineSpacingRule = rule;
        dyLineSpacing = space*20;
     end; 	
     SendMessage(RE.Handle, EM_SETPARAFORMAT, 0, Longint(@ParaFormat));
    end;

  5. #5
    Membre actif Avatar de XeGregory
    Homme Profil pro
    Passionné par la programmation
    Inscrit en
    Janvier 2017
    Messages
    313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Marne (Champagne Ardenne)

    Informations professionnelles :
    Activité : Passionné par la programmation
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Janvier 2017
    Messages : 313
    Points : 273
    Points
    273
    Par défaut
    Citation Envoyé par Paul TOTH Voir le message
    ben

    si bLineSpacingRule = 0 Espacement unique. Le membre dyLineSpacing est ignoré. (1,00)
    si bLineSpacingRule = 1 Un espacement et demi. Le membre dyLineSpacing est ignoré. (1,50)
    si bLineSpacingRule = 2 Espacement double. Le membre dyLineSpacing est ignoré. (2,00)
    si bLineSpacingRule = 3 ou 4 Le membre dyLineSpacing spécifie l’espacement d’une ligne à la suivante, en twips.
    si bLineSpacingRule = 5 La valeur de dyLineSpacing / 20 est l’espacement, en lignes, d’une ligne à l’autre.

    donc si tu veux 1,15, il faut la règle 5 et multiplier par 20 donc dyLineSpacing = 23, puisque 23/20 = 1.15

    enfin c'est comme ça que je le comprend
    Bonjour Paul TOTH

    J'ai fait un test d'écrire un texte dans le Wordpad sur chaque ligne j'ai mis un espacement entre les lignes différentes, ensuite j'ai de copier ce texte dans le RichEdit et avec ma fonction GetLineSpacing je récupère la valeur de chaque interligne.

    Résultat :

    1: dyLineSpacing = 20
    1,15: dyLineSpacing = 23
    1,50: dyLineSpacing = 30
    2,00: dyLineSpacing = 40

    Effectivement il faut multiplier Valeur interligne * 20 = dyLineSpacing ou l'inverse dyLineSpacing / 20 = Valeur interligne

    Merci Paul TOTH

  6. #6
    Membre actif Avatar de XeGregory
    Homme Profil pro
    Passionné par la programmation
    Inscrit en
    Janvier 2017
    Messages
    313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Marne (Champagne Ardenne)

    Informations professionnelles :
    Activité : Passionné par la programmation
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Janvier 2017
    Messages : 313
    Points : 273
    Points
    273
    Par défaut
    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
    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
    type
      TFLineSpacing = class(TForm)
        ListLineSpacing: TRadioGroup;
        { Form Show }
        procedure FormShow(Sender: TObject);
        { ListLineSpacing Click }
        procedure ListLineSpacingClick(Sender: TObject);
      private
        { Private declarations }
        { SetLineSpacing }
        procedure SetLineSpacing(RichEdit: TRichEdit; LineSpacing: Byte);
        { GetLineSpacing }
        function GetLineSpacing(RichEdit: TRichEdit): Byte;
      end;
     
    var
      FLineSpacing: TFLineSpacing;
     
    implementation
     
    {$R *.dfm}
     
    uses
      Unit1;
     
    { SetLineSpacing }
    procedure TFLineSpacing.SetLineSpacing(RichEdit: TRichEdit; LineSpacing: Byte);
    var
      ParaFormat: ParaFormat2;
    begin
      FillChar(ParaFormat, SizeOf(ParaFormat), 0);
     
      with ParaFormat do
      begin
        cbSize := SizeOf(ParaFormat2);
        dwMask := PFM_LINESPACING;
        bLineSpacingRule := 5;
        dyLineSpacing := LineSpacing;
      end;
     
      SendMessage(RichEdit.Handle, EM_SETPARAFORMAT, 0, Longint(@ParaFormat));
    end;
     
    { GetLineSpacing }
    function TFLineSpacing.GetLineSpacing(RichEdit: TRichEdit): Byte;
    var
      ParaFormat: ParaFormat2;
    begin
      FillChar(ParaFormat, SizeOf(ParaFormat), 0);
      ParaFormat.cbSize := SizeOf(ParaFormat2);
      SendMessage(RichEdit.Handle, EM_GETPARAFORMAT, 0, Longint(@ParaFormat));
      Result := ParaFormat.dyLineSpacing;
    end;
     
    { Form Show }
    procedure TFLineSpacing.FormShow(Sender: TObject);
    begin
      case GetLineSpacing(Form1.RichEdit) of
        20:
          ListLineSpacing.ItemIndex := 0;
        23:
          ListLineSpacing.ItemIndex := 1;
        30:
          ListLineSpacing.ItemIndex := 2;
        40:
          ListLineSpacing.ItemIndex := 3;
        50:
          ListLineSpacing.ItemIndex := 4;
        60:
          ListLineSpacing.ItemIndex := 5;
      else
        ListLineSpacing.ItemIndex := 0;
      end;
    end;
     
    { ListLineSpacing Click }
    procedure TFLineSpacing.ListLineSpacingClick(Sender: TObject);
    const
      LineSpacing = 20;
    var
      ValInt: Byte;
    begin
      ValInt := 0;
      ValInt := Trunc(LineSpacing * StrToFloat(ListLineSpacing.Items.Strings
        [ListLineSpacing.ItemIndex])); // Strings = (1,00 - 1,15 - 1,50) etc...
     
      SetLineSpacing(Form1.RichEdit, ValInt);
    end;

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

Discussions similaires

  1. Réponses: 3
    Dernier message: 28/09/2006, 17h18
  2. [TAG] Convertir une valeur numérique en hh:mm:ss
    Par Rafiki dans le forum Taglibs
    Réponses: 6
    Dernier message: 09/06/2006, 13h21
  3. Convertir une valeur d'une zone de texte en date
    Par os_rasta dans le forum ASP
    Réponses: 17
    Dernier message: 27/02/2006, 15h56
  4. Convertir la valeur d'un handle
    Par ni0urk dans le forum MFC
    Réponses: 5
    Dernier message: 07/01/2006, 12h31
  5. Convertir des valeurs hexadécimal en integer
    Par Bernard Martineau dans le forum Langage
    Réponses: 4
    Dernier message: 11/10/2005, 16h59

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