4

debug time

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.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
NemoPeti
  • 79
  • 1
  • 7

1 Answers1

5

You are calling the wrong method. Instead of GetPropValue you need GetMethodProp. Like so:

TNotifyEvent(GetMethodProp(MenuItem, 'OnClick'));
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490