Link to home
Start Free TrialLog in
Avatar of PeterLarsen
PeterLarsen

asked on

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
Avatar of rwilson032697
rwilson032697

Try declaring setname like this:

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

Cheers,

Raymond.
Yep, that's it...   :-)
Avatar of PeterLarsen

ASKER

Is the difference that you moved it to protected ?? If it is so, i have done that before :-(
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.
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
ASKER CERTIFIED SOLUTION
Avatar of hubdog
hubdog

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the reminder.
Peter