Recent

Author Topic: TStringGrid.OnPrepareCanvas - when does it fire  (Read 2810 times)

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
TStringGrid.OnPrepareCanvas - when does it fire
« on: July 03, 2015, 07:45:19 am »
As the title say, when does OnPrepareCanvas fire in the grand scheme of things. Unfortunately the API Class documentation[1] doesn't elaborate on that. We have a StringGrid with custom drawing using OnDrawCell, but where does OnPrepareCanvas fit in, and why would I use the OnPrepareCanvas, when I could do all the Canvas stuff I need in the OnDrawCell?


Links:
   
« Last Edit: July 03, 2015, 12:51:20 pm by Graeme »
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

balazsszekely

  • Guest
Re: TStringGrid.OnPrepareCanvas - when does it fire
« Reply #1 on: July 03, 2015, 11:31:24 am »
OnPrepareCanvas is fired just before OnDrawCell(grids.pas-->line 9838).
If you use custom drawing, you don't need OnPrepareCanvas(basically it's useless), as you said you can do all the canvas stuff in the OnDrawCell. On default draw instead, just before OnPrepareCanvas is called, a  lot of things are going on, like painting the selected raw, setting canvas font, etc...(for more details see line 3562).

Graeme

  • Hero Member
  • *****
  • Posts: 1428
    • Graeme on the web
Re: TStringGrid.OnPrepareCanvas - when does it fire
« Reply #2 on: July 03, 2015, 12:53:19 pm »
Many thanks for the information. So in our case OnPrepareCanvas is definitely not needed.
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://fpgui.sourceforge.net/

wp

  • Hero Member
  • *****
  • Posts: 11923
Re: TStringGrid.OnPrepareCanvas - when does it fire
« Reply #3 on: July 03, 2015, 01:08:34 pm »
The grid's wiki page is extremely useful for someone trying to learn more about the grid. I definitely prefer it over the "official" documentation.

Grid drawing is explained in

 

TinyPortal © 2005-2018