Custom component Convertion from delphi 5 to delphi 7 -
recently got chance convert delphi-5 code delphi-7. @ first started converting custom components delphi-7. while compiling delphi-5 components in delphi-7 system throwing error stating
"undeclared identifier: iformdesigner".
after googling came know iformdesigner should replaced idesigner. after replacing iformdesigner idesigner , separating design code runtime code, of components got compiled. while compiling below piece of code getting compiled successfully. when place component on form system throwing access violation error @
path:=idesigner(tform(fformowner).designer).getprivatedirectory in delphi7.
below component code.
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:=iformdesigner(tform(fformowner).designer).getprivatedirectory-- delphi 5 code path:=idesigner(tform(fformowner).designer).getprivatedirectory else path:=extractfilepath(application.exename); . . end;
the designer property of type idesignerhook , cannot hard cast idesigner. have hope of success need code of form:
(fformowner tform).designer idesigner this perform runtime query of idesignerhook interface designer, , return idesigner interface if interface indeed supported.
Comments
Post a Comment