简体   繁体   中英

Delphi assign event in class

I have to change the data type mapping for my custom query class (i am using FireDAC ). This is no problem itself, i have already created a procedure that does the job. But i hit a wall while implementing it on a big scale. I have created a procedure in my class which gets the self.FormatOptions.MapRules property from it's database connection component (which has the right data type mapping rules). Now i wanna change my class so every component of that class executes my procedure OnOpen but i can't seem to find a way do assign a procedure to an event in a class.

Is there a way to do that or "inherit" that property from my database connection component when it's not the parent of my query component?

I already tried doing it with the constructor but since i don't create the query component in runtime, the constructor is not called

Since the query component is used some 500+ times in the project i don't wanna assign the procedure to the event every time by hand...

OK, i just "solved" it. The problem was inside my class hirachy. It was like;

  • Top Layer : TMyCustomClass
  • Middle : TMygenerealClass
  • Bottom : TStandardClass

In The Middle class the default for Dataset.formatoptions.ownmaprules was set to true, which broke the heritage. Basically i had a lack of understanding how heritage works ;)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM