On Sun, Feb 3, 2013 at 1:44 PM, Mattias Gaertner <nc-gaert...@netcologne.de> wrote: > On Sun, 3 Feb 2013 13:32:09 +0200 > Juha Manninen <juha.mannine...@gmail.com> wrote: > No. The Notification is inherited from TComponent. So, it's about > Owner, not about TControl.Parent. Most controls are owned by the form.
Ok. >> I solved the problem by checking if the control's parent = Self. > > Good. 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. Comments ? Juha -- _______________________________________________ Lazarus mailing list Lazarus@lists.lazarus.freepascal.org http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus