<br><br><div class="gmail_quote">On Fri, Jan 14, 2011 at 10:38 PM, Torsten Bonde Christiansen <span dir="ltr"><<a href="mailto:tc@epidata.dk">tc@epidata.dk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi List.<br>
<br>
Is it possible to jump a couple of levels in the inherited hierarchy when calling "inherited" on a method?<br>
<br></blockquote></div><br>Hmm, don't know whether you're the same person or not :), but I replied in a stackoverflow question the next day after it was asked (see here: <a href="http://stackoverflow.com/questions/4662744/delphi-how-to-call-inherited-inherited-ancestor/4670457#4670457">http://stackoverflow.com/questions/4662744/delphi-how-to-call-inherited-inherited-ancestor/4670457#4670457</a> ) and it looked like the host didn't notice :). At least this variant seemed to work<br>
<br>code is self-explanatory<br><br>type<br> TGrandParent = class(TObject)<br> public<br> procedure Show;virtual;<br> end;<br><br> TParent = class(TGrandParent)<br> public<br> procedure Show;override;<br> end;<br>
<br> THackParent = class(TGrandParent)<br> private<br> procedure CallInheritedShow;<br> end;<br><br> TMyObject = class(TParent)<br> public<br> procedure Show;override;<br> end;<br><br><br>{ TGrandParent }<br>
<br>
procedure TGrandParent.Show;<br>begin<br> MessageDlg('I''m the grandparent', mtInformation, [mbOk], 0);<br>end;<br><br>{ TParent }<br><br>procedure TParent.Show;<br>begin<br> inherited;<br> MessageDlg('I''m the parent', mtInformation, [mbOk], 0);<br>
end;<br><br>{ THackParent }<br><br>procedure THackParent.CallInheritedShow;<br>begin<br> inherited Show;<br>end;<br><br>{ TMyObject }<br><br>procedure TMyObject.Show;<br>begin<br> THackParent(Self).CallInheritedShow;<br>
end;<br><br>procedure TForm6.Button6Click(Sender: TObject);<br>var<br> Obj: TMyObject;<br>begin<br> Obj:=TMyObject.Create;<br> try<br> Obj.Show;<br> finally<br> Obj.Free;<br> end;<br>end;<br>+<br><br><br>Max<br>