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 > SubSystem
Change this value to
Windows (/SUBSYSTEM:WINDOWS)
-
Change the Project Entry Point
Project > Properties > Configuration Properties > Linker > Advanced > Entry Point
Change this value to
main
. Apply these changes and close the Properties window. -
Open the
.cpp
file 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.
В Visual Studio 2012 нет шаблона «Приложение Windows Forms» для Visual C++:
Разработчики из Microsoft решили убрать такую возможность. (А может это очередная попытка пересадить всех на C# для проектов WinForms… не знаю). Тем не менее решение существует. И даже 2.
Решение 1 (мне больше нравится)
Взято отсюда.
Шаг 1. Скачать архив VS2012CPPWinForms.zip (3 Кб) (оригинал)
Шаг 2. Разархивировать в «C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcprojects\vcNET\»
Шаг 3. (Пере-) запустить VS 2012 и создать проект «Visual C++» > «CLR» > «Приложение Windows Forms».
Решение 2 (мне, вообще, не нравится)
Шаг 1. Создать проект «Приложение Windows Forms» в Visual Studio 2010 (или другой более ранней версии). Выбор версии .NET на данном этапе несущественен.
Шаг 2. Открыть созданный проект в Visual Studio 2012. Потребуется обновить файлы до более поздней версии Visual Studio (2012):
Видим снизу:
Обновление проекта "WinForms_NET4"... Конфигурация "Debug|Win32": изменение набора инструментов платформы на "v110" (был набор "v100"). Конфигурация "Release|Win32": изменение набора инструментов платформы на "v110" (был набор "v100"). TargetFrameworkVersion = v4.5 (прежнее значение v4.0) ========== Обновление проектов VC++: успешно: 1, с ошибками: 0, не требуют обновления: 0 ==========
Шаг 3. Используя меню «ФАЙЛ» > «Экспорт шаблона…» запускаем мастер создания шаблона.
Если в имени шаблона задать русские буквы, то появится предупреждение. Нажимаем «Да».
На последнем этапе мастера указывалось местоположение выходных файлов. В этой папке будет находится копия файла шаблона. Сам файл шаблона будет в папке «%USERPROFILE%\Documents\Visual Studio 2012\Templates\ProjectTemplates»:
Файл «Приложение Windows Forms.zip» можно скачать по ссылке.
По организации файлов-шаблонов рекомендую почитать How to: Locate and Organize Project and Item Templates.
Теперь собственно можно создавать приложения на C++ с использованием Windows Forms:
Рекомендую почитать:
http://stackoverflow.com/questions/11130915/windows-form-clr-application-in-visual-studio-2012-rc
Создание приложения Windows Forms с помощью .NET Framework (C++)
Проблемы с SP1
Рекомендую установить последний пакет обновлений (service pack). Например, в SP3 устранена проблема с компиляцией проекта при использовании внешних графический файлов в PictureBox. Ссылка на видео.
Edit, Download, and Sign the How to Create a Windows Form Application in Visual Studio 2012
Form
eSign
Add Annotation
Share Form
How do I fill this out?
How to fill out the How to Create a Windows Form Application in Visual Studio 2012?
Who needs the How to Create a Windows Form Application in Visual Studio 2012?
How PrintFriendly Works
Edit your How to Create a Windows Form Application in Visual Studio 2012 online.
Add your legally-binding signature.
Share your form instantly.
How do I edit the How to Create a Windows Form Application in Visual Studio 2012 online?
What are the instructions for submitting this form?
To submit this form, ensure all sections are completed accurately. You may do this via email by sending the filled form to submissions@domain.com, or by utilizing the online submission portal accessible through our website. Make sure to follow any additional instructions provided within the form itself.
What are the important dates for this form in 2024 and 2025?
Important dates for form submissions can vary, but users should be aware of deadlines in 2024 and 2025 for specific projects. Always check announcements for any upcoming changes or updates.
What is the purpose of this form?
The purpose of this form is to guide developers in creating Windows Form applications using Visual Studio 2012. It simplifies the development process by providing clear, concise steps for proper setup and configuration. Additionally, it serves as a reference for best practices in UI design.
Tell me about this form and its components and fields line-by-line.
This form consists of several key components essential for creating a Windows Form application.
- 1. Project Configuration: Allows developers to set up initial project settings and parameters.
- 2. Windows Form: The UI element where users can design and interact with their application.
- 3. Code Behind: Contains the logic and functionality related to the UI components.
- 4. Debugging Properties: Settings used to facilitate debugging during development.
What happens if I fail to submit this form?
If you fail to submit this form, you may miss essential guidelines or configurations necessary for project success. This could lead to project delays or issues during application deployment.
- Configuration Errors: Incorrect configurations may result in application failures.
- Lack of Features: Failure to submit may lead to missing critical application features.
- Inconsistencies in Development: Not submitting can cause discrepancies in team projects, complicating collaboration.
How do I know when to use this form?
Use this form when you are starting a new Windows Form application project in Visual Studio 2012. It is essential for ensuring all necessary templates and configurations are set correctly before development begins.
- 1. New Project Setup: Initiate projects that require Windows Form applications.
- 2. Educational Reference: Serve as a guideline for students learning C++ and Windows UI development.
- 3. Professional Development: Support professionals in adhering to best practices for application design.
Frequently Asked Questions
You can edit the PDF by opening it in PrintFriendly’s editor and using the editing tools provided.
Is it easy to add my signature?
Yes, adding your signature is simple with our signing tool; just upload or draw your signature.
Can I share the PDF with others?
Absolutely! PrintFriendly allows you to share your PDF via email or through a shareable link.
How do I customize the document?
Customization is easy; just use the editing features to change text, images, or layout.
Yes, once you’ve edited the PDF, you can download the final version to your device.
Do I need to sign up to edit?
No, you can edit and download PDFs without creating an account.
What formats can I export to?
You can export your edited document back to PDF for easy sharing.
Is there a limit on editing?
No, you can edit your PDF as many times as you need before downloading.
Can I combine multiple PDFs?
Yes, PrintFriendly allows you to merge different PDFs into one document.
Are there any tools to help with formatting?
Yes, our editor includes several formatting tools to enhance your document’s appearance.
Related Documents — VS2012 Windows Form App Guide
C# Windows Forms Application
In this tutorial will learn how to create windows-based application in visual studio 2012 with c# language.
We will learn step by step about C# windows Forms application.
We use vs2012 for creating windows application project. In our previous post we have already learnt about creating web application using visual studio 2010. In .net we can develop windows form application using c# or vb or c++ language same as we can develop Website application using c#, vb, c++.
Lets start with visual studio 2012 to create new windows application project.
For Create Windows Form application
open visual studio 2012 –> File Menu –> New –> Project
Start to create a new C# Windows Forms Application Project
Open visual Studio 2012 and select New –> Project option from File Menu as shows in below figure.
When we create a new windows forms application in visual studio, at that time we have language selection option which we wish to use in our windows application as server side programming language.
Here, we have selected c# language for our windows application as shows in below figure. As figure shows select Windows Forms Application option and at the bottom of figure there is Location portion for assign the path to store windows application. In Name portion, we write windows application project name.
Language –> Visual C#
File Menu –> New –> Project –> Windows Forms Application
Here, in above figure the location “D:\PROJECT\” is our windows application project location folder path where we store/save our project and the “MyFirstProject” is the windows application name which we created. After making this things click on OK button to create a new blank Windows Forms Application.
Here, we successfully created Windows forms Application with a windows form Form1. In below figure shows Solution Explorer which displays whole project details include Windows Forms, Settings files, Class files and Folders.
Here, windows application project forms known as Windows Form, and in web application it known as Web Form.
Below figure display the code behind page of windows forms where it allow programmer to write c# programming coding. We can see the Form1_Load method in below figure, the Form1_Load method is called each time when our page is loaded.
We hope that this c#.net post helped you to understand about how to create windows application.
Next, c# windows application tutorial we will understand about how to set .net framework.
Applies ToVisual Studio Ultimate 2013 Visual Studio Ultimate 2013 Visual Studio Premium 2013 Visual Studio Premium 2013 Visual Studio Professional 2013 Visual Studio Professional 2013 Visual Studio Express 2013 for Windows Visual Studio Express 2013 for Windows Visual Studio Ultimate 2012 Visual Studio Premium 2012 Visual Studio Express 2012 for Windows 8 Visual Studio Express 2012 for Windows Desktop
Symptoms
The follow project wizards no longer exist in Microsoft Visual Studio 2012 and Microsoft Visual Studio 2013 as Microsoft Visual C++ templates:
-
Windows Form Application
-
Windows Form Control Library
Therefore, you can’t create new projects based on Visual C++ templates for Windows Form Application and Windows Form Control Library in Visual C++/CLI (Common Language Infrastructure).
Cause
Windows Form Application and Windows Form Control Library wizards in C++/CLI have been removed from Visual Studio 2012 and Visual Studio 2013.We recommend that you do not create Windows Forms applications in C++/CLI and instead use C++/CLI for interoperability only.
Visual Studio 2012 and Visual Studio 2013 will still support existing Windows Form Application and Windows Form Control Library in C++/CLI UI applications that were made previously by using Microsoft Visual Studio 2008 or Visual Studio 2012.
Status
This behavior is by design and is a recent change in Visual Studio 2012 that is continued in Visual Studio 2013.
For more information about breaking changes in Visual C++ in Visual Studio 2012, go to the following MSDN website:
http://msdn.microsoft.com/en-us/library/bb531344(v=vs.110).aspx
Need more help?
Want more options?
Explore subscription benefits, browse training courses, learn how to secure your device, and more.