At startup, load an image containing the desired wall picture. Then, in the OnDrawCell
event handler, check the grid's Cells
value and if W
is detected then Draw()
that image on the grid's Canvas
. It doesn't really get any simpler than that.
class TForm1 : public TForm
{
__published:
TStringGrid *StringGrid1;
void __fastcall StringGrid1DrawCell(TObject* Sender,
int ACol, int ARow, const TRect &Rect, TGridDrawState State);
private:
Graphics::TBitmap *WallBmp;
public:
__fastcall TForm1(TComponent *Owner);
__fastcall ~TForm1::TForm1();
};
__fastcall TForm1::TForm1(TComponent *Owner)
: TForm(Owner)
{
WallBmp = new Graphics::TBitmap;
// fill image as needed - load a file or
// a resource, hand draw directly on
// WallBmp->Canvas, etc...
}
__fastcall TForm1::~TForm1()
{
delete WallBmp;
}
void __fastcall TForm1::StringGrid1DrawCell(TObject* Sender,
int ACol, int ARow, const TRect &Rect, TGridDrawState State)
{
...
if (StringGrid1->Cells[ACol][ARow] == "W")
StringGrid1->Canvas-Draw(WallBmp, Rect.Left, Rect.Top);
...
}