Reputation: 79
I need to convert a Variant
to TNotifyEvent
, but can't.
As the image shows I use GetPropValue
to get the OnClick
property of a TMenuItem
. I must compare this to another TNotifyEvent
, so I must convert it also to TNotifyEvent
.
In runtime this is always type of TNotifyEvent
, but the code not compile, when I try to cast it to TNotifyEvent
.
How can I make it work? Unfortunately I have only Delphi version 5, so the RTTI capabilities are limited.
Upvotes: 4
Views: 193
Reputation: 613461
You are calling the wrong method. Instead of GetPropValue
you need GetMethodProp
. Like so:
TNotifyEvent(GetMethodProp(MenuItem, 'OnClick'));
Upvotes: 5