Renaming a form in Visual C ++

I am starting Microsoft Visual Studio 2010. I decided to start a new project on the welcome page. Of course, my preferred language is Visual C ++, and I suggest starting a Windows Forms application. I refuse a name such as a calculator for this. I do not touch other parameters in this dialog box. A project is created, and a new Form1.h project is automatically added to the project, and Form1.resX is also added. Since "Form1" is useless to me, I would like to rename it to something more than VB6-style, for example, "frmMain.h". So I directly click on the form and just select "Rename." After accepting my new name, the necessary changes seem to be happening. First impression. But now, when I try to build this project, it gives BUILD FAILURE. When I look into my files .. Form1 is still mentioned.

So my question is: how do you actually / OFFICIALLY rename forms?

I read a lot about this, and basically the answer is to delete the form and add a new name with the correct name. I also heard that VS asks to rename all links to it, but it did not seem to me. Some other people say that you should use the quick replace function and rename all references to this class and its file. This is not a good way for me .. Or is it really a standard procedure?

I have experience in C ++ programming and I know about classes and polymorphism and so on. But this is one of the simplest things that annoys me!

+4
source share
2 answers

You use VC ++. NET to create .NET applications (a Windows form in your case). I must warn you that VS is not very friendly to VC (refactoring, renaming and little intellisense).

In this case, you renamed the form, which will force VS to also rename Form1.resX, but it will not rename the class. It will do this if in C # or VB.NET. Just open the .h file and rename the class itself so that it matches the file name.

You also need to update the main .cpp file, where "main" is, and update Application :: Run (gcnew Form1 ()); there also include "#include".

The solution will replace the job (Ctrl + Shift + H), but be careful with this.

+5
source

click on the form -> properties -> text (usually called Form1) -> change it.

0
source

Source: https://habr.com/ru/post/1388536/


All Articles