[Lazarus] Putting class method names in a stringlist

Mattias Gaertner nc-gaertnma at netcologne.de
Tue Jan 20 10:26:38 CET 2015


On Tue, 20 Jan 2015 01:46:52 +0100
kapibara <kapibara.pas at aol.com> wrote:

> I have been trying for some days to create a combobox with names of 
> event handlers. The handlers are many and resides in its own class. I 
> cant find out how to get the names of the methods into the combobox, 
> except hardcoding them. Do I really have to add manually the names of 
> the class methods?
> 
> Below: assigning the handler, by selecting from the combobox.
> 
> EventHandlerName:= MyComboBox.Items[MyComboBox.ItemIndex];
> MyObject.OnEvent:= MyEventHandlers.MethodAddress(EventHandlerName);

1. Make the methods "published".
2. 

    ti := obj.ClassInfo;
    PropCnt := GetPropList(ti, propList);
    try
      for i := 0 to PropCnt - 1 do begin
        if propList^[i]^.PropType^.Kind<>tkMethod then continue; 
        writeln('methodname: ',propList^[i]^.PropType^.Name);
      end;
    finally
      FreeMem(propList);
    end;

Mattias




More information about the Lazarus mailing list