yoyo269
Messages postés
1403
Date d'inscription
lundi 23 février 2004
Statut
Membre
Dernière intervention
11 janvier 2009
2
9 avril 2005 à 22:43
Voilà une fonction que j'ai faite se servant notamment de la couleur.
Si tu as besoin de précisions, je suis là.
/*Ajoute du texte à une RichEdit avec une police définie*/
void AjouteTexte(HWND Handle, char * Texte, char * Pseudo, char * Police, COLORREF Couleur, int Style, char * Type)
{
CHARFORMAT2 Format;
CHARRANGE Selection;
static char Chaine[TAILLEBUFFER + ZERO_FIN];
if (!strcmp(Type, "Texte"))
{
ZeroMemory(&Format, sizeof(CHARFORMAT2));
Format.cbSize = sizeof(CHARFORMAT2);
Format.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE;
Format.dwEffects = 0;
Format.yHeight = 170;
Format.yOffset = 0;
Format.crTextColor = RGB(0, 0, 0);
Format.bCharSet = ANSI_CHARSET;
Format.bPitchAndFamily = DEFAULT_PITCH;
sprintf(Format.szFaceName, "%s", "MS Sans Serif");
Selection.cpMin = strlen(PrendreTexte(Handle));
Selection.cpMax = strlen(PrendreTexte(Handle));
sprintf(Chaine, "%s%s", Pseudo, " dit :\r\n ");
SendMessage(Handle, EM_EXSETSEL, 0, (LPARAM) &Selection);
SendMessage(Handle, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &Format);
SendMessage(Handle, EM_REPLACESEL, 0, (LPARAM)(LPCTSTR) Chaine);
ZeroMemory(&Format, sizeof(CHARFORMAT2));
Format.cbSize = sizeof(CHARFORMAT2);
Format.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE;
Format.dwEffects = Style;
Format.yHeight = 170;
Format.yOffset = 0;
Format.crTextColor = Couleur;
Format.bCharSet = ANSI_CHARSET;
Format.bPitchAndFamily = DEFAULT_PITCH;
sprintf(Format.szFaceName, "%s", Police);
Selection.cpMin = strlen(PrendreTexte(Handle));
Selection.cpMax = strlen(PrendreTexte(Handle));
sprintf(Chaine, "%s%s", Texte, "\r\n");
SendMessage(Handle, EM_EXSETSEL, 0, (LPARAM) &Selection);
SendMessage(Handle, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &Format);
SendMessage(Handle, EM_REPLACESEL, 0, (LPARAM)(LPCTSTR) Chaine);
SendMessage(Handle, WM_VSCROLL, SB_BOTTOM, 0);
}
if (!strcmp(Type, "Message"))
{
ZeroMemory(&Format, sizeof(CHARFORMAT2));
Format.cbSize = sizeof(CHARFORMAT2);
Format.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE;
Format.dwEffects = Style;
Format.yHeight = 170;
Format.yOffset = 0;
Format.crTextColor = Couleur;
Format.bCharSet = ANSI_CHARSET;
Format.bPitchAndFamily = DEFAULT_PITCH;
sprintf(Format.szFaceName, "%s", "MS Sans Serif");
Selection.cpMin = strlen(PrendreTexte(Handle));
Selection.cpMax = strlen(PrendreTexte(Handle));
sprintf(Chaine, "%s%s%s", ">>> ", Texte, " <<<\r\n");
SendMessage(Handle, EM_EXSETSEL, 0, (LPARAM) &Selection);
SendMessage(Handle, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &Format);
SendMessage(Handle, EM_REPLACESEL, 0, (LPARAM)(LPCTSTR) Chaine);
SendMessage(Handle, WM_VSCROLL, SB_BOTTOM, 0);
}
if (!strcmp(Type, "Envoi"))
{
ZeroMemory(&Format, sizeof(CHARFORMAT2));
Format.cbSize = sizeof(CHARFORMAT2);
Format.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE;
Format.dwEffects = Style;
Format.yHeight = 170;
Format.yOffset = 0;
Format.crTextColor = Couleur;
Format.bCharSet = ANSI_CHARSET;
Format.bPitchAndFamily = DEFAULT_PITCH;
sprintf(Format.szFaceName, "%s", Police);
SendMessage(Handle, EM_SETCHARFORMAT, SCF_ALL, (LPARAM) &Format);
}
if (!strcmp(Type,"Ajout"))
{
ZeroMemory(&Format, sizeof(CHARFORMAT2));
Format.cbSize = sizeof(CHARFORMAT2);
Format.dwMask = CFM_BOLD | CFM_COLOR | CFM_FACE | CFM_ITALIC | CFM_SIZE | CFM_UNDERLINE;
Format.dwEffects = Style;
Format.yHeight = 170;
Format.yOffset = 0;
Format.crTextColor = Couleur;
Format.bCharSet = ANSI_CHARSET;
Format.bPitchAndFamily = DEFAULT_PITCH;
sprintf(Format.szFaceName, "%s", Police);
Selection.cpMin = strlen(PrendreTexte(Handle));
Selection.cpMax = strlen(PrendreTexte(Handle));
SendMessage(Handle, EM_EXSETSEL, 0, (LPARAM) &Selection);
SendMessage(Handle, EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM) &Format);
SendMessage(Handle, EM_REPLACESEL, 0, (LPARAM)(LPCTSTR) Texte);
SendMessage(Handle, WM_VSCROLL, SB_BOTTOM, 0);
}
}
YOYO, @+.
YOYO