1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::StringGrid1DrawCell(TObject *Sender, int ACol,
int ARow, TRect &Rect, TGridDrawState State)
{
int i, j, X, Y;
TRect R;
if(State.Contains(gdFixed))
{
// Les cellules fixes sont toujours dessinées en gris
StringGrid1->Canvas->Brush->Color = clBtnFace;
StringGrid1->Canvas->Brush->Style = bsSolid;
StringGrid1->Canvas->FillRect(Rect);
}
else if(State.Contains(gdSelected))
{
// Les cellules sélectionnées sont en bleue
StringGrid1->Canvas->Brush->Color = clNavy;
StringGrid1->Canvas->Brush->Style = bsSolid;
StringGrid1->Canvas->FillRect(Rect);
}
else
{
// Recherche de la zone image à copier pour tenir compte des décalages
// de la grille en fonction des barres de défilement.
X = 0;
for(i = StringGrid1->FixedCols + 1; i <= ACol; i++) (X++, StringGrid1->ColWidths [i]);
{
Y = 0;
for(i = StringGrid1->FixedRows + 1; i <= ARow; i++) (Y++, StringGrid1->RowHeights[i]);
{
R.Left = X;
R.Right = X + Rect.Right - Rect.Left;
R.Top = Y;
R.Bottom = Y + Rect.Bottom - Rect.Top;
// Dessin d'une partie de l'image
Image1->Visible = false;
// D:\\Copie_USB\\Sauvegarde mes documents C\\Mes images\\Massiv10\\Massiv10\\Bitmaps\\Arrow
Image1->Picture->Bitmap->LoadFromFile("D:\\Copie_USB\\Sauvegarde mes documents C\\Mes images\\Massiv10\\Massiv10\\Bitmaps\\Arrow\\arcarrow1.bmp");
// "C:\\Documents and Settings\\blondelle\\Mes documents\\Mes images\\Massiv10\\Massiv10\\Bitmaps\\Arrow\\arcarrow1.bmp"
StringGrid1->Canvas->CopyRect(Rect, Image1->Picture->Bitmap->Canvas, R);
StringGrid1->Canvas->Brush->Style = bsClear;
}
}
}
// Sélection de la couleur de texte
if(State.Contains(gdSelected))
{
SetTextColor(StringGrid1->Canvas->Handle, clWhite);
}
else
{
SetTextColor(StringGrid1->Canvas->Handle, clBlack);
}
// Dessin du texte en utilisant la fonction API
DrawText(StringGrid1->Canvas->Handle, (StringGrid1->Cells[ACol][ARow]).c_str(), -1, &Rect, DT_NOPREFIX );
}
//--------------------------------------------------------------------------- |
Partager