[fpc-pascal] 2.1.1 new protected

Graeme Geldenhuys graemeg.lists at gmail.com
Fri Aug 11 15:45:00 CEST 2006


On 8/11/06, Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
> Where do you read here anything about 'current instance'?

Maybe not in that snippet of text, but I read it somewhere...  ;-)


> And it was very Delphi compatible. I mean, how many Delphians noticed the difference at all? It didn't hurt and gave more flexibility. So, I second Michael's proposal to at least keep it in mode objfpc.


Maybe it is only me, but I am used to the Delphi way.  It made you
think twice about accessing methods deep in a hierachy (normally
hidden).  I do agree it will make it easier to access protected
methods, but not so sure if that is a good thing.

I created a few classes as shown below, but doing this made me think
about it first, before blindly accessing methods.

  { Create a friend class so we can access the protected AddAction method. }
  TActionListFriend = class(TActionList)
  end;

And used it as follows....

  aOK                     := TAction.Create(self);
  aOK.Caption             := csOK;
  aOK.OnExecute           := @aOKExecute;
  { Must add to list otherwise it doesn't execute }
  TActionListFriend(FActionList).AddAction(aOK);


This reminds me, Mattias, must TActionList.AddAction be protected?  I
had to do the above to create actionlists via code and get the actions
to execute correctly.


Regards,
  - Graeme -

-- 
There's no place like 127.0.0.1



More information about the fpc-pascal mailing list