title: Need guidance on drawing PNGs into a Delphi XE6 TDrawGrid
body: <p>I'm using a drawgrid to display a "dungeon" map. I have an array filled with data describing what types of physical features are located in each cell. The basic layout of rooms and corridors, etc. There's a PNG for each permutation.</p>
  
  <p>I'm trying to "draw" the map by drawing the appropriate PNG into each cell of the drawgrid. I can do it more or less directly using <strong>DrawGrid1.Canvas.Draw(x,y,pngImage)</strong>, but figuring out the exact x,y in pixels is frustrating because of the gridlines (at least, I'm finding it frustrating), and I'm not sure what other issues I'll run into down the road.</p>
  
  <p>I also tried <strong>pngImage.Draw(DrawGrid1.Canvas,Rect)</strong>, but once again, I have to calculate the Rect, which really seems unnecessary as the cells and PNGs are all 40x40 pixels.</p>
  
  <p>Reading related articles and examples, OnDrawCell seems to be a better way, because given ARow and ACol, the Rect for the given cell is apparently precalculated (unless I'm misinterpreting what I've read in several places). But none of the examples I've found actually show how OnDrawCell is triggered. The easy answer "when something gets drawn into a cell" doesn't really explain it much better. <strong>That's</strong> what I'm trying to do.</p>
  
  <p>(I've often found this to be the case with Delphi's documentation: How is explained (not always exactly for your given use case), but when or why is left shrouded in mystery..)</p>
  
  <p>Of course, there are a few other things to figure out as well, like controlling the drawgrid so it doesn't erase the PNG when a cell is clicked..</p>
  
  <p>Any relevant suggestions will be greatly appreciated. TFRM</p>