My feeling is that adding controls to the grid makes things very complicated - but ok: my solution is not easy either... In the Paint procedure the grid paints the cells, fixed cells and grid lines - this is where the OnDrawCell event originates. Then, since the grid has children now, it paints the children. In this second phase the clip rect is defined by the grid's bounds, not by the fixed cells - therefore your controls are painted over the fixed cells. You cannot intercept OnDrawCell since this already has been called when the controls are painted. The only thing I could imagine would be to intercept the Paint method (you need a descendant stringgrid to get access to it!) and after calling inherited you must redefine the cliprect to the rectangle without the fixed cells. Then, the controls hopefully will respect the new, smaller cliprect to be cut off at the fixed cells.
I don't know if this works, and I don't know if this is simpler than my method of just painting images over the completed grid. But you'll defininitely also need a new class inherited from TStringGrid, similar to my solution.
OnDrawCell (which would work within the standard StringGrid) might work if - like in my approach - you paint the images over the grid. You must store a list of the image bitmaps and their positions, i.e. the cells where they are anchored plus their offset from the anchor coordinates (again, like in my solution). Then, in the OnDrawCell event you iterate through the image list and calculate the intersection of the cell rectangle (known as a parameter of the OnDrawCell event) and the rectangle occupied by each image. The image position must be calculated to be relative to the cell, i.e. it must take care of the Top/Left scrolling offset. Due to the cliprect of the OnDrawCell event only the part of the image being inside the cell rect will be painted. If the image reaches into the adjacent cell the procedure will be repeated for that new section if the image.
There are two disadvantages:
- If the image is large it will be painted as often as there are cells into which it is reaching
- Since the cell border is drawn after painting the cell content you will still see the cell border lines as if they were painted on top of the image.