begin process at 2010 02 09 19:34:42
  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 COMBINAISONS DE STRINGS par askil2000
Source avec Zip Source avec une capture RECONNAISSANCE DE CARACTÈRES (OCR) par Bacterius
Source avec Zip Source avec une capture NETTOYAGE AUTOMATIQUE DE NOMS DE FICHIERS par John Dogget
DISTANCE DE JARO-WINKLER par PoulpHunter
Source avec Zip BASE DE DONNÉE WIKI par thithony

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...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

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,608 sec (4)

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