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?
 
hubdogConnect With a Mentor Commented:
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
 
rwilson032697Commented:
Try declaring setname like this:

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

Cheers,

Raymond.
0
 
MadshiCommented:
Yep, that's it...   :-)
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
PeterLarsenAuthor Commented:
Is the difference that you moved it to protected ?? If it is so, i have done that before :-(
0
 
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
 
PeterLarsenAuthor Commented:
Thanks for the reminder.
Peter
0
All Courses

From novice to tech pro — start learning today.