j_kour Posted April 24, 2023 Share Posted April 24, 2023 Hi, TUniForm does not pass correct information to RTTI. Say, you have this declaration: type TMainForm = class(TUniForm) private { Private declarations } public procedure sayHi; end; The RTTI code should should reveal all the methods in the class. var fCtx: TRttiContext:= TRttiContext.Create; var form: TMainForm:=MainForm; var rtype: TRttiType:= fCTx.GetType(form.ClassInfo); var gg: TArray<string>; for var method: TRttiMethod in rtype.GetMethods do begin SetLength(gg, Length(gg) + 1); gg[Length(gg) - 1]:=method.Name; end; fCtx.Free; gg array should list all the methods in the class but it misses the sayHi method. Unfortunately, forcing the compiler to inspect all methods using the following directive does not work {$RTTI METHODS([vcPublic, vcProtected, vcPrivate])} On the other hand, if you declare the following class TTestClass = class private procedure method1; public procedure method2; end; and run the same code gg lists method2 (but, strangely, not method1???). I suspect the function that returns TMainForm messes up RTTI. Can anyone think of any work around? Quote Link to comment Share on other sites More sharing options...
风吹小机机 Posted April 25, 2023 Share Posted April 25, 2023 Which version of UNIGUI are you using Some versions prohibit RTTI transmission Quote Link to comment Share on other sites More sharing options...
j_kour Posted April 25, 2023 Author Share Posted April 25, 2023 I changed this {$RTTI METHODS([vcPublic, vcProtected, vcPrivate])} to this {$RTTI EXPLICIT METHODS([vcPublic, vcProtected, vcPrivate])} and it works now. This directive forces RTTI to ignore RTTI information from the ancestor classes and treat each class independently. The downside is I have to add the directive to every class but it is not such a big deal. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.