(在OnDrawCell事件中的程式碼會在切換頁籤或呼叫Refresh()函式時會執行)
//在一開始已設定DoubleBuffered為true, 防止刷新時畫面閃爍
DrawGrid2->ColCount = g_Width;
DrawGrid2->RowCount = g_Heigh;
Graphics::TBitmap *bmp_temp=new Graphics::TBitmap;
for (int i=0 ; i<g_Heigh ; i++)
{
for (int j=0 ; j<g_Width ; j++)
{
//設定R1的大小
TRect R1;
R1.left=0;
R1.top = 0;
R1.right=30;
R1.bottom = 30;
if (mark[i][j]==1)
{
//將Image1縮放為R1的大小, 並填入DrawGrid[j, i]中
bmp_temp=Image1->Picture->Bitmap;
DrawGrid2->Canvas->CopyRect(DrawGrid2->CellRect(j,i), bmp_temp->Canvas,R1);
}
else if (mark[i][j]==2)
{
//將Image2縮放為R1的大小, 並填入DrawGrid[j, i]中
bmp_temp=Image2->Picture->Bitmap;
DrawGrid2->Canvas->CopyRect(DrawGrid2->CellRect(j,i), bmp_temp->Canvas,R1);
}
else if (mark[i][j]==3)
{
//將Image3縮放為R1的大小, 並填入DrawGrid[j, i]中
bmp_temp=Image3->Picture->Bitmap;
DrawGrid2->Canvas->CopyRect(DrawGrid2->CellRect(j,i), bmp_temp->Canvas,R1);
}
}
}