Как определить, является ли метод потомком TNotifyEvent
Автор: Jack Sudarev
WEB-сайт: http://www.lmc-mediaagentur.de
If I am given a TPersistent object, and a method name, is there a way to determine if the name is an event of TNotifyEvent type? For example, given a TPersistent lMyObj and an event name, "OnDataChanged", how can I determine if OnDataChanged is a TNotifyEvent?
function IsNotifyEvent(Sender: TObject; const Event: string): Boolean;
var
PropInfo: PPropInfo;
Method: TNotifyEvent;
begin
Result := False;
PropInfo := GetPropInfo(Sender.ClassInfo, Event);
if not Assigned(PropInfo) then
Exit;
if PropInfo.PropType^.Kind <> tkMethod then
Exit;
Method := TNotifyEvent(GetMethodProp(Sender, PropInfo));
Result := Assigned(Method);
end;
|