Bonjour,
Apres plusieurs recherches, pour afficher une couleur gradient, j'ai reussi à adapter ce code trouvé sur les forums. Sauf que je ne le comprends pas.
StringGrid avec pour seule Option : RowSelect
Dans Form1.GridDrawCell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| procedure TFormMenu.GridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
........
{Tracer un rectangle dans la cellule}
Rect:=CellRect(ACol,ARow); // Enlever les marges pour remplir entierement la cellule
FillRect(Rect); // Remplir la zone rectangulaire avec le pinceau en cours
if (gdSelected in State) then
begin
DrawingStyle:=gdsGradient;
Brush.Style:=bsClear; // Rect est transparent
GradientFillCanvas(Canvas, GetShadowColor(clHighlight, 45), GetShadowColor(clHighlight, 10), Rect, gdVertical);
StyleServices.GetElementColor(StyleServices.GetElementDetails(tgCellSelected), ecGradientColor1, StartColor);
StyleServices.GetElementColor(StyleServices.GetElementDetails(tgCellSelected), ecGradientColor2, EndColor); |
Si je ne mets pas cette ligne, rien ne s'affiche :
GradientFillCanvas(Canvas, GetShadowColor(clHighlight, 45), GetShadowColor(clHighlight, 10), Rect, gdVertical);
Alors quel est l'interet de ce code ?
1 2
| StyleServices.GetElementColor(StyleServices.GetElementDetails(tgCellSelected), ecGradientColor1, StartColor);
StyleServices.GetElementColor(StyleServices.GetElementDetails(tgCellSelected), ecGradientColor2, EndColor); |
Merci
Partager