Topic: Using "with...do" causing Stack overflow in main script

V6.20

In all other subunits (uses ...) there is no error.

e.g. TImageList -> error

with imgList16 do
begin
  Masked    :=false;
  ColorDepth:=cd32bit;
  ...
end;

e.g. with TForm -> ok.

with frmMain do
begin
  width :=100;
  height:=100;
  ...
end;

2 (edited by CDB 2019-12-21 11:50:18)

Re: Using "with...do" causing Stack overflow in main script

I wonder if you should have

with FORM_NAME.imgList16 do //Eg: frmMain.imgList16
begin
  Masked    :=false;
  ColorDepth:=cd32bit;
  ...
end;
On a clear disk you can seek forever

3 (edited by cbnbg 2019-12-21 13:33:05)

Re: Using "with...do" causing Stack overflow in main script

Thanks for your suggestion but...

It's declared like that:

var
  imgList16: TImageList;
  imgList32: TImageList;
  ...

and then created in main block on startup:

imgList16 := TImageList.Create(frmMain);

Its owner is frmMain, so it will be destroyed on closing main form.
It is not accesible by frmMain.imgList16 (Undeclared identifier: 'imglist16'). Perhaps it happens 'cause it's a nonvisual component and/or has no parent.