2010. augusztus 21., szombat

How to create a DrawGrid with a non-scrolling background image


Are there any sources available for a DrawGrid (or kind of) with a bitmap in the background (wallpaper under the whole grid that isn't scrolled) ? I know i can draw the bitmap in the OnDrawCell event. But if the grid is scrolled, then the whole canvas is scrolled (including the background bitmap) and only the new cells are receiving a draw-message.


This should get you started:

TExtDrawGrid = class(TDrawGrid)
  procedure WMEraseBkGnd(var Msg: TWMEraseBkGnd); message WM_ERASEBKGND;

procedure TExtDrawGrid.WMEraseBkGnd(var Msg: TWMEraseBkGnd);
  Canvas.Draw(ClientRect.Left, ClientRect.Top, TheBackgroundBitMap);

Setting the DefaultDrawing property to false will prevent the grid from overwriting the back ground with standard cell display. You can decide what gets drawn on top of the background for any given cell. Maybe override the paint method to clean up before the rest gets slapped on top.

Nincsenek megjegyzések:

Megjegyzés küldése