I am using a TMS object inspector at run time, but assume my question would be equally valid for Delphi at design time.
I want to have a property which can be set programically (at run time) or hard coded (at design time). It should be visible to the user as the information is useful to him and it should be changeable at run-time by the program but not by the user via the object inspector.
I tried
published property FileName : String read FFileName;
and the property is visible, but it is also changeable in the object inspector (and throws a read of address zer0 exception when changed) 🙁
This looks like a perfectly valid and correct read-only property
if you add an extra property that public and thus only settable during runtime you’re in business:
However if you want to hack it and get rid of the exception in Design-time
change it to:
What I think might also be going on…
Disconnect between designtime and runtime code
In order to change the runtime behaviour of the code you need only change the source code and remove the
write ...part of the property.This will not effect the design-time code though, for that you need to reinstall the component.
If you change the source code of a registered component and you keep the changes within the
private,protectedand/orpublicsections of the component you are usually OK.However if you change the
publishedpart of a component and you do not reinstall that component you will have abnormal behaviour at startup.This is because in design-time you are still working with the old/unchanged binary versions of the component. This version has not had the
writepart removed and allows you to change the underlying stringFFilename.Come runtime the init-code will read the form resource 1) and spots a value to be written to FFilename. However the procedure
SetFilenameis no longer available and therefore a access violation occurs during program startup.1) (the data that was in the .dfm file and is now stored inside a dfm resource in your .exe)