Article

From:
To:
Brian Cook
Subject:
Re: How to allow only one child component within a TWinControl?
Newsgroup:
borland.public.delphi.vcl.components.writing

Re: How to allow only one child component within a TWinControl?

In article <✉newsgroups.borland.com>, Brian Cook wrote:
> Do you realize that funtionally there is absolutely no difference? The only > place that ValidateInsert is called is from ValidateContainer. They are, in
> essence, exactly the same method.  

Not true:

procedure TComponent.ValidateContainer(AComponent: TComponent); begin   AComponent.ValidateInsert(Self); end;
procedure TComponent.ValidateInsert(AComponent: TComponent); begin end;
Note that in ValidateContainer, self is the component about to be inserted into AComponent, whereas in ValidateInsert, self is the component which AComponent is about to be inserted into. Overriding ValidateContainer has absolutely no effect on the components being inserted into self.
procedure TWinControl.InsertControl(AControl: TControl); begin   AControl.ValidateContainer(Self);    translates to   Self.ValidateInsert(AControl);   
> ValidateInsert could actually be removed
> from the VCL with no adverse affect.
>

If you only use the VCL classes, yes, because it doesn't do anything. It needs 
to be there so it can be overridden :)

Renate
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Fri, 29 Mar 2024 09:01:48 UTC
Copyright © 2009-2024
HREF Tools Corp.