Recent

Author Topic: Run time crash using tmodStringGrid = class(tStringGrid).  (Read 1167 times)

iru

  • Sr. Member
  • ****
  • Posts: 331
Run time crash using tmodStringGrid = class(tStringGrid).
« on: April 26, 2021, 02:12:11 am »
Environment: Linux Mint 20, Laz 2.0.12, fpc 3.2.0.

I have a main form with two StringGrids. I wish to add a couple of functions to move data from IBQuery fields to the cells in the grids.

Program compiles clean and executes.

Created a modified StringGrid with

  tModStringGrid = class(tStringGrid)
     Function LoadQ(InQ : tIBQuery) : String;
     ...
     ...
  end;

On the main form changed the origional StringGrids types to tModStringGrid and tidied up a few things.

Compiled clean, no errors.

On executing the program it CRASHES in the .lpr on Application.CreateForm(TFormMain, FormMain);
The exception is EClassNotFound, class tStringGrid not found.

The 'assembler' display shows 'CLASSES$_$TREADER_$__$$_FINDCOMPONENTCLASS$ANSISTRING$$TCOMPONENTCLASS'.

If I insert a 'DummyStringGrid : tStringGrid' into the FormMain the program compiles and RUNS correctly, NO crash.
The DummyStringGrid is not accessed or used in any way.

So am I doing something really odd or do we have a bug???

Any ideas, brilliant insights appreciated, Ian.

iru

  • Sr. Member
  • ****
  • Posts: 331
Re: Run time crash using tmodStringGrid = class(tStringGrid).
« Reply #1 on: April 27, 2021, 02:15:47 pm »
Thank you for the response. I will implement and check in the next couple of days. Rather busy at the moment.

Ian

lucamar

  • Hero Member
  • *****
  • Posts: 4217
Re: Run time crash using tmodStringGrid = class(tStringGrid).
« Reply #2 on: April 27, 2021, 02:54:08 pm »
All you need to do is add the unit "Grids" (where TStringGrid is declared) to your (interface) uses clause.

Lazarus makes this happen automatically when you add a control to the form, which is why adding a dummy string grid works.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

 

TinyPortal © 2005-2018