Search code examples
delphieventsfiredac

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...


Solution

  • 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 ;)