Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Registry and FindComponent

Status
Not open for further replies.

majlumbo

Programmer
Jul 13, 2010
295
US
Do you get the access violation the first time through the for loop, last time, or every iteration through the loop?

I would set a breakpoint at the line you get the AV on, and compare the actual name of the TPanel with 'Panel'+P to see if they match. Not finding the component itself won't give you an AV, but using the result (as you are doing with WriteInteger) will produce an AV if findcomponent returned nil.
 
Hi majlumbo

Many thanks for the reply, I did just as you suggested and found the problem. I’m almost too embarrassed to say but all the test programs I tried had only three panels! Yet the loop tried to find six.
It’s a good job I don’t have to earn a living as a programmer :)

 
If you create (and thus need to free) any components manually, and you know you'll have a number of similar ones, you may consider saving them in a list, such as TStringList.Objects or just a straight TList, and freeing them from the list as they're deleted (upon closing)

JD Solutions
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top