Where I wrong?

ginsonic
ginsonic used Ask the Experts™
on
I try to create a dinamicaly browsers array. When I close my application I get an error message " invalid pointer operation" .... bla bla bla.

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, OleCtrls, SHDocVw_TLB, EmbeddedWB;

type
  TForm1 = class(TForm)
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  web  : array of TEmbeddedWB;
implementation

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
  SetLength(Web,1);
  Web[1]:=TEmbeddedWB.Create(Self);
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  Web[1].Free;
end;
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hi,

I think that Web array is zero-based with your way of declaration. So, you may change:

SetLength(Web,2);

or

use Web[0]instead of Web[1].

Regards, Geo
VGR

Commented:
you can solve all your problems by using "normal" array declaration, not an open one.

array [1..cMaxOfYourChoice] of TEmbeddedWB;

should solve your problem

Author

Commented:
Thanks Geo :)
My pleasure ! Thanks for the points :-)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial