cs_dugueclin
Messages postés66Date d'inscriptionjeudi 2 septembre 2004StatutMembreDernière intervention10 juillet 2012
-
6 mai 2012 à 18:09
cs_dugueclin
Messages postés66Date d'inscriptionjeudi 2 septembre 2004StatutMembreDernière intervention10 juillet 2012
-
7 mai 2012 à 02:01
bonjour à tous;
j'utilise un stringgrid
j'insert une image dans la colonne[8]du stringgrid, ça fonctionne bien.
procedure TForm1.StringGridDrawCell(Sender: TObject; ACol, ARow: Integer;
begin
With Sender As TStringGrid Do With Canvas Do
IF (Acol = 8)And(ARow>=1) and (StringGrid.cells[8, Arow]='0') then
begin
DrawText(Canvas.Handle, PChar(Cells[ACol,ARow]), -1, Rect, DT_CENTER);
Imagelist1.draw(StringGrid.Canvas, rect.left-1, rect.top +1, 0);
end;
end;
Si dans la cellule le chiffre "0" est saisi, alors, l'image s'affiche, mais le texte n'est pas masqué et je voudrais ne le masquer.
j'ai chercjé en changant les dimensions du canvas(rect.left et rect.top), mais le texte reste toujours affiché.
l'image est une coche d'ou l'importance de masquer le texte.
En vous remercient d'avance,
Sincères salutations et bon codding
Duguesclin
cs_walidlam
Messages postés107Date d'inscriptionlundi 30 mai 2011StatutMembreDernière intervention29 avril 20131 6 mai 2012 à 20:22
salut !!
essayer avec cette procedure:
procedure TForm1.StringGridDrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var R:TRect;
begin
With Sender As TStringGrid Do With Canvas Do
IF (Acol = 8)And(ARow>=1) and (StringGrid.cells[8, Arow]='0') then
begin
FillRect(Rect);
Font.Color:=clWhite ;
TextOut(Rect.Left,Rect.Top,Cells[ACol,ARow]);
Imagelist1.draw(StringGrid.Canvas, rect.left+1, rect.top +1, 0);
DrawText(Canvas.Handle, PChar(Cells[ACol,ARow]), -1, Rect, DT_CENTER);
end;
end;
{si ca marche alors click sur bonne repense @+}
Cirec
Messages postés3833Date d'inscriptionvendredi 23 juillet 2004StatutModérateurDernière intervention18 septembre 202250 6 mai 2012 à 20:32
Salut,
si j'ai bien compris ton problème:
procedure TForm1.StringGridDrawCell(Sender: TObject; ACol, ARow: Integer;
begin
with Sender as TStringGrid do with Canvas do
if (Acol = 8)and(ARow>=1) then
if (StringGrid.cells[8, Arow]='0') then
Imagelist1.draw(StringGrid.Canvas, rect.left-1, rect.top +1, 0)
else
DrawText(Canvas.Handle, Char(Cells[ACol,ARow]), -1, Rect, DT_CENTER);
end;
cs_dugueclin
Messages postés66Date d'inscriptionjeudi 2 septembre 2004StatutMembreDernière intervention10 juillet 2012 7 mai 2012 à 00:37
bonjour Cirec et Walidlam,
merci à vous de m'avoir répondu, c'est bien le code que j'ai, mais, je sais pas pourquoi il marche pas dans mon programme final, j'ai fais une maquette et il fonctionne à merveille !!
et dans mon prog final ..NON!!
il faut redéfinir les positions -1 et le texte est caché.
merci encore à vous deux, je vais continuer à chercher.
sincères salutations et bon codding
Duguesclin
cs_dugueclin
Messages postés66Date d'inscriptionjeudi 2 septembre 2004StatutMembreDernière intervention10 juillet 2012 7 mai 2012 à 02:01
oui merci
voilà le code final
With Sender As TStringGrid Do With Canvas Do
begin
If gdFixed in State Then
Brush.Color := clBtnFace
Else If gdSelected In State Then
Brush.Color := $00F0FFFF
Else If Odd(ARow) Then
Brush.Color := $00F0FFFF;
Font.Style:=[];
FillRect(Rect);
If (gdSelected In State) Then
SetTextColor(Canvas.Handle,clBlue)
Else
SetTextColor(Canvas.Handle,clBlue);
If (gdFixed In State) Then
SetTextColor(Canvas.Handle,clBlack);
DrawText(Canvas.Handle, PChar(Cells[ACol,ARow]), -1, Rect , DT_LEFT);
begin
IF (Acol = 2)And(ARow>=1) And (StringGrid.cells[2, Arow]='2') then
begin
FillRect(Rect);
SetTextColor(Canvas.Handle,clBlue);
Imagelist.draw(StringGrid.Canvas, rect.left +20, rect.top+1, 0);
end;
end;
end;
j'ai changé la colonne zet ça marche!!!! rect.left +20 merci Cirec
super sympat
problème résolu
Sincères Salutations et bon codding
Duguesclin