4

I tried to search for my error, read some topics, but I couldn't find a hint why it would be happening. If someone could help me to at least get some hint of how I can check out what is happening, so I`m able to fix it, it would be greatly appreciated.

I have coding an application that has several bpl linked together to form the executable.
I have a form and a frame on the same project. When I try to add the frame to the form, it gives me a "List index out of bounds" error. I can add other frames that are in this project to this form, but I cannot add this frame to this form or other forms of the project, but the frame is added to the project.

Thanks in advance for any help

Thomas

Ken White
  • 123,280
  • 14
  • 225
  • 444
Thomas
  • 51
  • 4
  • What is the *exact* text of the error message? And what controls are on the TFrame that you can't add? – Ken White Nov 16 '10 at 19:31
  • List index out of bounds (-1). Prior to that I get an error message: "Can NOT Find these Files. Maybe They`re in Different Projects." From what I could infere, this error message is given by CnPack. The form and the frame are in the same project, so I cant understand why this other message does show up. – Thomas Nov 16 '10 at 19:34
  • http://img217.imageshack.us/img217/3826/projecth.png Dataacess controls (dbexpress), edit, combo, panel, pagecontrol, all native delphi components. I`m trying to add the form at design. – Thomas Nov 16 '10 at 19:39
  • As the message seems to be given by CnPack, have you tried disabling this library's design time packages so its editors and wizards can't interfere? If you are then able to add the frame to your form, that would be a strong indication where to look for the cause of the messages... – Marjan Venema Nov 16 '10 at 19:50

3 Answers3

3

"List index out of bounds (-1)" is an interesting error. If I had to guess, I'd say somewhere it's executing code that looks like this:

Index := List.IndexOf(Whatever);
List.Delete(index);

If your controls are contained in BPLs, there's a way you can track it down in the debugger. Open the BPL where the frame you're trying to place is located. Build it in Debug mode. Then go to the Run menu and select Parameters.... Under Host Application, hit Browse and find bds.exe (the Delphi IDE itself,) and then hit F9. This will launch a second copy of the IDE and load debug info for your BPL.

Then try to reproduce the error, and when the list error occurs, it'll be treated by your first copy of Delphi as any other exception, with the opportunity to break and enter the debugger. From there you should be able to track down the problem easily enough.

Mason Wheeler
  • 82,511
  • 50
  • 270
  • 477
  • The error is being given at design time. I just get the component (frame) and drop it on the form. Sorry, forgot to say it was at design time. – Thomas Nov 16 '10 at 19:47
  • 2
    @Thomas: I know it's at design time. What I just described is how you debug design time errors. – Mason Wheeler Nov 16 '10 at 19:50
1

I was able to fix the problem by removing and adding the frame again to the project.

Thanks for the help, Ken and Marjan.

Thanks for teaching me how to debug design time errors, Mason, I not even knew that was possible. Its always nice to learn new things.

And thanks for yours fast response.

Thomas

Thomas
  • 51
  • 4
0

I've got the same problem. Though the error message comes from CnWizards indeed, it has nothing to do with it.

In my case, the cause was the corrupted *.dproj file that is being overwritten by Delphi. You have to fix it on your own.

You have to find all entries of <DesignClass>TFrame</DesignClass> - it is a standard entry for any frame. You should insert the following line before:

<FormType>dfm</FormType>

Save the project file, check if the problem still occurs. The solution is explained more thoroughly in this post.

Jacek Krawczyk
  • 2,083
  • 1
  • 19
  • 25