delphi - TypeCasting : what is difference between below 2 lines of code? -
what difference between below 2 lines of code. both trying path , 1 working , other throwing error. working on delphi-7
path:= (((fformowner tform).designer) idesigner).getprivatedirectory; --working path:= idesigner(tform(fformowner).designer).getprivatedirectory ; --error
below code using line of code path.
constructor tsamplecomponent.create(aowner: tcomponent); begin inherited create(aowner); fformowner:=tform(owner); if not (owner tform) repeat fformowner:=tform(fformowner.owner); until (fformowner tform) or (fformowner.owner=nil); if (csdesigning in componentstate) path:= (((fformowner tform).designer) idesigner).getprivatedirectory else path:=extractfilepath(application.exename); . . end;
idesigner(tform(fformowner).designer)
this performs simple reinterpretation cast of designer
. fail because designer
of type idesignerhook
not same idesigner
.
(fformowner tform).designer) idesigner
this performs runtime query idesigner
, resolved call queryinterface
. correct way obtain different interface existing one.
Comments
Post a Comment