Hab zwar nix direkt mit visuellen Komponenten zu tun, aber mit der VCL und dem Initialisierungsverhalten:
Ich schreib eine neue Komponente TMutexIPC = class(TComponent) und habe dort ein Ereignis, dass nach dem Anlegen eines Mutex (funzt), eines MMF (funzt) und eines Window-Handles (funzt auch) ein Ereignis OnMutexCreate ausführen soll. Schematisch sieht die Kompo (aufs nötigste Begrenzt) etwa so aus:
Delphi-Quelltext
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25:
| unit MutexIPC;
uses ...;
type TOnMutexCreateEvent = TNotifyEvent;
type TMutexIPC = class(TComponent) private FOnMutexCreate:TOnMutexCreateEvent; public procedure AfterConstruction; override; property OnMutexCreate:TOnMutexCreateEvent read FOnMutexCreate write FOnMutexCreate; end;
implementation
Procedure TMutexIPC.AfterConstruction; Begin If Assigned(FOnMutexCreate) Then FOnMutexCreate(Self); end; end. |
Problem ist nun, dass er FOnMutexCreate NICHT aufruft und erst NACH Beendigung von AfterConstruction initialisiert. Somit wird das OnMutexCreate-Event nicht ausgeführt, obwohl er es, nach dem entsprechenden Aufruf ordentlich zuweist.
Achso, zu erwähnen wäre noch, dass in der Forms.pas die TCustomForm AUF GENAU DIE GLEICHE ART UND WEISE initialisiert wird und dort funktioniert dieser Quelltext bekanntermaßen.
P.S.: Der derzeitige (Komplett-)Unitquelltext umfasst circa 800 Programmzeilen und soll später mal eine Komponente für Inter-Prozess-Kommunikation werden. 80% sind schon etwa fertig, aber dieser Bug macht die Komponente nahezu unbrauchbar, da neben dem OnMutexCreate auch das OnMutexClientLogin (automatische Benachrichtigung über neuen IPC-Teilnehmer) des aktuellen Clients verschluckt wird.
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.