Yes this is true Max BUT...really all I am savingt to the registry is wether the checkbox is checled or not, ot he color selected in a color combo, or the text in a text box...I am not saving ALL the properties of a control. Have I given the impression that I was saving ALL the properties of a control? I hope I didnt.....
Jeremy -----Original Message----- From: "Max Nilson" <[EMAIL PROTECTED]> To: Multiple recipients of list delphi <[EMAIL PROTECTED]> Date: Wed, 2 Oct 2002 10:28:43 +1200 Subject: RE: [DUG]: Checkbox > Jeremy Coulter asks: > > > What I want it for is a properties page where the user sets up what > they > > want the app to look like etc. so saving specific properties like > > IndexItem, Value, text etc. of the components based on their type, is > > the best way to go. > > and later mentioned: > > > Ok, but how do I access the values? i.e. How do I read say > > checkbox10...as an example to see if its checked or not? > > so it looks like he is essentially trying to read and write component > properties to the registry. > > There are two basic methods that you can use to achieve this sort of > thing, > and the differencve lies in how you want to handle backwards > compatibility > when component are updated over time. > > The first mechanism is to simply overload the standard Delphi streaming > code > and read and write the DFM stuff into a registry value. Code something > like > this is a start: > > Mem := TMemoryStream.Create; > Mem.WriteComponent(ACheckBox); // Dumps propertes into stream > with TRegistry.Create do > try > if not OpenKey('Software\MyApplication\Componentdata') then > raise Exception.Create('Registry failure!'); > WriteBinaryData(ACheckBox.Name, PChar(Mem.Memory)^, Mem.Size); > finally > Destroy > end > > and do the reverse on the way back in, that is read the registry data > into a > memory stream, reset the memory stream to the start and use > ReadComponent to > read the properties back in again. For more on this sort of technique > you > need to read around in Classes.pas to see how Borland wrote all teh > Delphi > streaming code. > > The only problem with this is that is you rename, delete or change the > allowable values of a property you have all sorts of problems reading > the > old format values back in again, because Delphi has no mechamism to > allow > for recovering from errors during property streaming. If you are never > going > tio change your properties then you have no problem otherwise you need > to > change the format of the saved vales from Delphi's DFM to your own > scheme. > > The basis of doing this is to do the above, but rather than using > WriteComponent you preform your own enumeration through the published > proporties and then write their values out in your format. I actually > do > this for our custom report designer and write the values I need to out > into > a sort of butchered CVS file and it works well. I have coded things so > that > I can detect versions of file and as the format changes I can adapt the > reader to handle old versions cleanly. > > Extra bonus marks would be to store all the enumerated property values > into > an XML file, as this would be the perfect combination of readable > output, > backwards compatibility and style, and have maximum sexyness. > > Cheers, Max. > > > ----------------------------------------------------------------------- > ---- > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > Website: http://www.delphi.org.nz > To UnSub, send email to: [EMAIL PROTECTED] > with body of "unsubscribe delphi" > Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/