Signals and slots implementation in Delphi?
Asked Answered
G

3

4

Does an implementation of the signals and slots mechanism for event dispatching exist for Delphi?

Gamba answered 22/7, 2011 at 9:45 Comment(2)
Non-multicast event handling is built in. It's just the multicast part that needs add-ons.Anacoluthia
I added a mixup of the suggested methods at bitbucket.org/MX4399/multicast-events-using-genericsGamba
S
4

Search for multicast events. There are a few implementations out there, e.g.

Some of them need generics, so are D>2009 only.

Selinski answered 22/7, 2011 at 9:48 Comment(2)
TApplicationEvents uses eventsink too.Willi
@Downvoter: I tried to use TApplicationEvents for my own multicast events once. Unfortunately it's designed mostly un-reuseable, like most of the VCL. :-/Selinski
P
2

Whilst you can implement multi-cast events yourself, they are not directly supported in the the language unlike in C# and VB.NET. Lack of language support makes any attempt to emulate multi-cast events rather clumsy.

Interestingly, C++ lacks support for signals and slots and the Qt solution involves an extra process in the compilation tool chain, the Meta Object Compiler.

Peale answered 22/7, 2011 at 9:59 Comment(1)
More importantly, the VCL and the IDE don't support whatever your implementation of multi-cast events is, making it's use clumsy. The language as-is could be used to implement nice multi-cast events, even implement the full-blown registration-free "signals and slots" thing (using RTTI Attributes). Using operator overloading you can almost get C# syntax working.Singletree
A
1

I spent some time a while ago getting Allen Bauer's Multicast Event code working. It has some limitations, but works well in my code. You can see the code here.

Of course, it only works in Delphi > 2009

Arak answered 22/7, 2011 at 23:47 Comment(1)
The original post from Allen only supported 32 bit. If you are looking for a version that supports 64 bit as well you can find it here: github.com/JensBorrisholt/OnlineOfflineRouault

© 2022 - 2024 — McMap. All rights reserved.