Recent

Author Topic: How to change the type name of form  (Read 2617 times)

simsee

  • Full Member
  • ***
  • Posts: 235
How to change the type name of form
« on: August 24, 2020, 01:24:33 pm »
I have some doubts about how to correctly change the type name (i.e. class name) of a form (for example, the default name TForm1 when opening a new project). In the past, if I remember correctly, I simply used the "Rename Identifier" function in the "Refactoring" menu, but now, with the latest version of Lazarus, I get a run time error (EResNotFound: Form Resource not found ...) . Therefore I am forced to update the corresponding .lfm file by hand. Is there a quicker (and perhaps correct) way? It seems to me that this problem did not exist in the past. Has something changed? I apologize for the trivial question. Thanks in advance.

PascalDragon

  • Hero Member
  • *****
  • Posts: 6356
  • Compiler Developer
Re: How to change the type name of form
« Reply #1 on: August 24, 2020, 01:32:48 pm »
In the Object Inspector, change the Name property of the form. The IDE will then rename your form class to TYourName (if you entered YourName as name).

simsee

  • Full Member
  • ***
  • Posts: 235
Re: How to change the type name of form
« Reply #2 on: August 24, 2020, 01:56:08 pm »
Thanks PascalDragon. I knew this possibility. Although I know that the following would not respect common naming conventions, I wanted to understand if there was a smarter way than the one I described to get DifferentFormName: TFormName.

dsiders

  • Hero Member
  • *****
  • Posts: 1556
Re: How to change the type name of form
« Reply #3 on: August 24, 2020, 05:42:21 pm »
Thanks PascalDragon. I knew this possibility. Although I know that the following would not respect common naming conventions, I wanted to understand if there was a smarter way than the one I described to get DifferentFormName: TFormName.

So you really want to change the name of the variable for the form instance?

Select the identifier in the code editor, and use the Source > Refactoring > Rename Identifier menu option. Verify that the new identifier name is also used in your project file (.lpr).
« Last Edit: August 24, 2020, 05:53:39 pm by dsiders »

 

TinyPortal © 2005-2018