Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-01

Putting class method names in a stringlist

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

kapibara

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);

Reply by email

Mattias Gaertner
to kapibara
Show quoted text 10 lines
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^.KindtkMethod then continue;
        writeln('methodname: ',propList^[i]^.PropType^.Name);
      end;
    finally
      FreeMem(propList);
    end;

Mattias

Reply by email

kapibara
to Mattias Gaertner

Wow! Thank you very much, Mattias !

Mattias Gaertner wrote 34 lines
On Tue, 20 Jan 2015 01:46:52 +0100 kapibara 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^.KindtkMethod then continue; writeln('methodname: ',propList^[i]^.PropType^.Name); end; finally FreeMem(propList); end; Mattias -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email