VS2008 C++ /CLI generated code formatting/placement issues
New to VS2008...
I am using CLR Forms to create a GUI. I put a button on the form and then ask the IDE to create a click event. VS2008 puts the code in the .h file and formats it 'badly' compared to our in-house guidelines.
How do i get the code into the .cpp file and format it correctly?
Worse, when I 'reset' the event, VS2008 does not remove the generated cod开发者_开发技巧e if I did any edits in it!
The managed code tools are mainly written for managed languages and in managed languages there is no header file so everything is in the source file. To port it to C++ it would be easier to just change file extension than to write the code to split generated code into header files and source files
Try the Edit.FormatDocument command (default shortcut CTRL + K, CTRL + D). The modification is limited by the settings specified on the Formatting pane of the C++ language in the Text Editor section of the Options dialog box. You can also use Edit.FormatSelection (ALT + F8 CTRL + K, CTRL + F) after selecting what you want to format. ActiveDocument.Selection.SmartFormat may work too, but I don't know its shortcut. You can create a macro/addin to call it.
There are other tools that can provides better control in formating the current file and some can be even used as external tools or add-ins in Visual Studio. Search "code beautifier visual C++" or "code formatting visual C++" in your favorite search engine to find them.
精彩评论