begin process at 2012 02 08 09:57:00
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Texte

 > MODIFIER LA COULEUR DE FOND DU TEXTE SÉLECTIONNÉ DANS UN RICHEDIT

MODIFIER LA COULEUR DE FOND DU TEXTE SÉLECTIONNÉ DANS UN RICHEDIT


 Information sur la source

 Description

Modifier la couleur de fond du texte sélectionné dans un RichEdit

Source

  • uses RichEdit;
  • // Met la couleur clYellow sur le fond du texte sélectionné
  • RE_SetSelBgColor(MyRichEdit, clYellow);
  • // Résupère la couleur clYellow sur le fond du texte sélectionné
  • myColor := RE_GetSelBgColor(MyRichEdit, clYellow);
  • procedure TFrmChild.RE_SetSelBgColor(RichEdit: TRichEdit; AColor: TColor);
  • var
  • Format: CHARFORMAT2;
  • begin
  • FillChar(Format, SizeOf(Format), 0);
  • with Format do
  • begin
  • cbSize := SizeOf(Format);
  • dwMask := CFM_BACKCOLOR;
  • crBackColor := AColor;
  • Richedit.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format));
  • end;
  • end;
  • function TFrmChild.RE_GetSelBgColor(RichEdit: TRichEdit): TColor;
  • var
  • Format: CHARFORMAT2;
  • begin
  • FillChar(Format, SizeOf(Format), 0);
  • with Format do
  • begin
  • cbSize := SizeOf(Format);
  • dwMask := CFM_BACKCOLOR;
  • Richedit.Perform(EM_GETCHARFORMAT, SCF_SELECTION, Longint(@Format));
  • result := Format.crBackColor;
  • end;
  • end;
uses RichEdit;

// Met la couleur clYellow sur le fond du texte sélectionné

RE_SetSelBgColor(MyRichEdit, clYellow);


// Résupère la couleur clYellow sur le fond du texte sélectionné

myColor := RE_GetSelBgColor(MyRichEdit, clYellow);


procedure TFrmChild.RE_SetSelBgColor(RichEdit: TRichEdit; AColor: TColor);
var
  Format: CHARFORMAT2;
begin
  FillChar(Format, SizeOf(Format), 0);
  with Format do
  begin
    cbSize := SizeOf(Format);
    dwMask := CFM_BACKCOLOR;
    crBackColor := AColor;
    Richedit.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format));
  end;
end;

function TFrmChild.RE_GetSelBgColor(RichEdit: TRichEdit): TColor;
var
  Format: CHARFORMAT2;
begin
  FillChar(Format, SizeOf(Format), 0);
  with Format do
  begin
    cbSize := SizeOf(Format);
    dwMask := CFM_BACKCOLOR;
    Richedit.Perform(EM_GETCHARFORMAT, SCF_SELECTION, Longint(@Format));
    result := Format.crBackColor;
  end;
end;



 Sources du même auteur

ENREGISTRE UN SITE WEB, LES LIENS ASSOCIÉS ET LES IMAGES CON...

 Sources de la même categorie

Source avec Zip Source avec une capture TABLEAU INFO SAVE INI par quentinix
Source avec Zip TIBWORD: EDITEUR ORIENTE LANGUE TIBÉTAINE par fredelem
Source avec Zip Source avec une capture POSTIT INFOS par dubois77
Source avec Zip Source avec une capture STREAM STRINGWRITER... UNE MICRO-LIBRAIRIE POUR ÉCRIRE DES C... par LaDentDeLait
Source avec Zip COMBINAISONS DE STRINGS par askil2000

Commentaires et avis

Commentaire de MANDRHAKE le 14/10/2006 10:01:26

Bonjour,
_J'ai une petite question:
Peut-on changer la couleur de fond du TRichEdit partie par partie sans avoir a sélectionner un texte?
_Dans ton code:
myColor := RE_GetSelBgColor(MyRichEdit, clYellow);
devrais être remplacé par:
myColor := RE_GetSelBgColor(MyRichEdit);

 Ajouter un commentaire




Nos sponsors


Sondage...

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,811 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales