Triggering the Name property wont work

I have a little problem with the name property on a form. And i dont know if its possible to do.
Everytime the component name is changed i would like to do somthing before the actually changing take place.

Type
  TempForm = class(TForm)
   public
    procedure SetName(const NewName: TComponentName); override;
  end;

implementation

procedure TempForm.SetName(const NewName: TComponentName);
begin
 showmessage(NewName);
 inherited; //(or Inherited SetName(NewName); )
end;

My problem is that SETNAME is never triggered. What am i doing wrong here ??

Regards
Peter
LVL 2
PeterLarsenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rwilson032697Commented:
Try declaring setname like this:

protected
    procedure SetName(const NewName: TComponentName); override;

Cheers,

Raymond.
0
MadshiCommented:
Yep, that's it...   :-)
0
PeterLarsenAuthor Commented:
Is the difference that you moved it to protected ?? If it is so, i have done that before :-(
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

rwilson032697Commented:
The difference is the override directive. Setname is defined originally as protected, and there's no need to promote it so you should leave it as that...

Cheers,

Raymond.
0
PeterLarsenAuthor Commented:
Sorry Raymond, but i think i need to explain my question a little better.

What i need is a designtime method to trace if or when the user change the name property on a form.

Actually, i dont need to know the name, i just want some unique identifier, a number would be fine.

This information is used by some components (placed on the form). If i use the name as a unique identifier i also most know if it is changed.

I can now see that SetName never will work, because i can't activate the code at designtime like a component.

Any suggestions ??

Regards
Peter
0
hubdogCommented:
hi peterlarsen
  if you want to response to user's  action on property name.you can write a propertyeditor override the default property editor like this

type
  tnewnameproperty=class(Tstringproperty)
  public
  procedure SetValue(const value:string);override;
  end;
implementation

procedure register;
begin
  registerpropertyeditor(typeinfo(TComponentName),tform,'Name',tnewnameproperty);
end;

function tnewnameproperty.SetValue(const Value:String);
begin
  showmessage('control name='+Value);
  inherited SetValue(Value);
end;

good luck

hubdog
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PeterLarsenAuthor Commented:
Thanks for the reminder.
Peter
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.