On Sun, 3 Feb 2013 13:58:42 +0200 Juha Manninen <juha.mannine...@gmail.com> wrote:
>[...] > In fact the control does not have parent or even name when > Notification is called. > Apparently the control is still under construction. If I set its > properties there, it leads to a crash. > I solved it by using OnIdle handler. Notification sets FNewControl and > registers the handler which looks like this : > > procedure TCustomCoolBar.OnIdle(Sender: TObject; var Done: Boolean); > var > Band: TCoolBand; > begin > Assert(Assigned(FNewControl) and Assigned(FNewControl.Parent), > 'TCoolBar.OnIdle: FNewControl or FNewControl.Parent not assigned'); > DebugLn(['TCoolBar.OnIdle, Control.Name=', FNewControl.Name]); > if FNewControl.Parent = Self then > begin > Band := FBands.Add; > Band.Control := FNewControl; > FNewControl := Nil; > end; > Application.RemoveOnIdleHandler(@OnIdle); > end; > > > It seems to work but may not be the cleanest way to do it. "Not to be the cleanest way" lol It's a dirty hack. Even an QueueAsyncCall would be better. > Comments ? Why not override InsertControl and RemoveControl? Mattias -- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus