Forum > General

Parent other than Form?

(1/2) > >>

Arvin:
Been a while since I used pascal....D6 about 10 years ago.

I have an array of TShapes created in FormCreate this way:


--- Code: --- for j := 1 to numberRows do
  begin
      for i := 1 to numberCols do
      begin
              shapeArray[(j-1)*numberRows+i]:= TShape.Create(Notebook1.Page[2]);
              shapeArray[(j-1)*numberRows+i].Parent:= Notebook1.Page[2];
              shapeArray[(j-1)*numberRows+i].OnMouseUp:= @ShapeMouseUp;
              shapeArray[(j-1)*numberRows+i].Shape:=stRectangle;
              shapeArray[(j-1)*numberRows+i].Width:=30;
              shapeArray[(j-1)*numberRows+i].Height:=20;
              shapeArray[(j-1)*numberRows+i].Left:=i*30-1;
              shapeArray[(j-1)*numberRows+i].Top:=(j-1)*20-1;
              shapeArray[(j-1)*numberRows+i].Brush.Color:=clRed;
              shapeArray[(j-1)*numberRows+i].Pen.Color:=clBlack;
       end;
  end;

--- End code ---

It compiles but when run it gives SEGFEP error code.

What's that? It worked fine when I was using Form1 as the parent, but I want this on a page of a notebook.

Any one see what's wrong?
Arvin

theo:
Are you sure your Notebook has 3 pages?
Notebook1.Page[2] is the third page (0,1,2).

Arvin:
It only has two. But the object inspector calls it number 2. I try 1.

Thanks for the reply.
Arvin

Arvin:
That seems to work.

It seems strange to show it as Page2 in the object inspector and then use zero based reference in the code.

Oh well. It's all in the details.
Thanks
Arvin

Now how do I mark it solved?

Arvin:
Had to compound the problem!

Put a Panel on the notebook page and when using it as owner I get an error that says: identifier idents no member "Panel1"

shortened code below.

TShape.Create(Notebook1.Page[1].Panel1);
Parent := Notebook1.Page[1].Panel1;

Actually when I put the period after the bracket I get no choices either.
So how do I create the shapes in the panel instead of the page?

Arvin

Navigation

[0] Message Index

[#] Next page

Go to full version