>> function FindControlForm(WC:TwinControl):Tform;
>> begin
>>   Result := nil;
>>   repeat
>>     if WC is TForm then Result := TForm(WC)
>>     else WC := WC.Parent;
>>   until WC=Result;
>> end;

> FindControlForm (Nil) -> Access Violation time.  Same thing if WC.Parent is
> Nil.

You were warned it didn't have the same side-effects... Note the request was for
a control that the programmer knew existed and WC.Parent does not cause a
exception since the until clause will break on WC=nil since Result at this point is 
nil...

I would suggest that giving an access violation if WC is nil at entry is consistent 
with
VCL behaviours and therefore a reasonable design.  I may be worth adding however a
raise as the last line if result=nil since most VCL behaviours look to prefer exception
throwing to nil results.  This is certainly a style issue however...

--
Aaron Scott-Boddendijk
Jump Productions
(07) 838-3371 Voice
(07) 838-3372 Fax


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to