Create a C++ Windows Form in Visual Studio 2012
The following is a simple step-by-step guide to creating a C++ Windows Form in Visual Studio 2012.
-
Add a new Project to the Solution
File > New > Project... > Visual C++ > CLR > CLR Empty Project -
Select the new Project in the Solution Explorer
-
Add a Windows Form to the Project
Project > Add New Item... > Visual C++ > UI > Windows Form -
Change the Project Subsystem
Project > Properties > Configuration Properties > Linker > System > SubSystemChange this value to
Windows (/SUBSYSTEM:WINDOWS) -
Change the Project Entry Point
Project > Properties > Configuration Properties > Linker > Advanced > Entry PointChange this value to
main. Apply these changes and close the Properties window. -
Open the
.cppfile associated with the Windows FormEnter the following code:
#include "MainWindow.h" using namespace System; using namespace System::Windows::Forms; [STAThread] void main() { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); Program::MainWindow mainWindow; Application::Run(%mainWindow); } -
Run the Application
You now have a very simple Windows Form in C++, ready to be built up with your other C++ projects.