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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access violation 00456A96 Read of address 0000338

Status
Not open for further replies.

JFChem

Programmer
Jul 30, 2001
4
US
This is crazy. I'm trying to change the caption on a label (class TLABEL) using a qualified name; e.g. Pform.hitNo.caption := 'trial' where Pform is the name of the form in which the label hitNo occurs. Pform is declared as type TPform inside a Main Form in a Unit called Partition. The Access Violation occurs no matter where I use Pform.hitNo--in event code such as OnShow, in my own procedure inside Partition or when I try to execute it in a Unit outside of Partition (with proper formulation of the Uses statement to allow communication). In all cases, the programs compiled without error. This is driving me nuts--I've used the same kind of qualified name in the same way dozens of times in dozens of programs. I am writing in Delphi 7.0. HELP!

John
 
hi,

if you get an access violation while you are updating components on a form the most probable cause wil be the non existing of the form. So make sure the form is created at the time you want to update information. The best place to update captions is in the onActivate

Steph [Bigglasses]
 
To get a look at what's going on, go to your Project | Options (ctrl-shift-F11), and on the Compiler page, make sure the Debugging options are all checked, and that the Optimize option is unchecked.

Then, breakpoint the line that's causing the problem. When you hit the breakpoint, hover the mouse over each part of the expression: first over Pform, then over hitNo, then over Caption.

As Steph says, almost certainly Pform will be nil. But this breakpoint-and-hover strategy is good for solving access violations in general.

-- Doug Burbidge mailto:dougburbidge@yahoo.com
 
Steph and Doug--Thanks a million--you were absolutely right. For reasons that I do not understand, my mainform, Pform didn't exist! Following your suggestion, I checked its pointer (which by the way is accessible under the Run/Evaluate option). I really don't know why it had a NIL pointer. The form appeared on the screen, I could add and delete components, the compiler never squawked, buttons on the form worked during execution--but no subroutine could see it! At any rate, I dumped the program and started over and this time checked the pointer to the mainform to make sure I got it right. So far, so good. Again, thank you both for removing my headache.

PS--Ain't the Internet wonderful!!!?

John
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top