Cast type of Delphi 5 to evaluated type Invalid display error

debug time

I need to convert Variantto TNotifyEventbut cannot.

As shown in the figure, I use GetPropValueto get the properties OnClickfor TMenuItem. I have to compare this with another TNotifyEvent, so I have to convert it also to TNotifyEvent.

In runtime, it is always a type TNotifyEvent, but the code does not compile when I try to apply it to TNotifyEvent.

How can I make it work? Unfortunately, I only have a version of Delphi 5, so RTTI's capabilities are limited.

+4
source share
1 answer

You are calling the wrong method. Instead GetPropValueyou need to GetMethodProp. For instance:

TNotifyEvent(GetMethodProp(MenuItem, 'OnClick'));
+5

Source: https://habr.com/ru/post/1689448/


All Articles