找不到 C++ 的 Windows 窗体应用程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32404247/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Can't find Windows Forms Application for C++
提问by Marked as Duplicate
I'm really new to visual studio and programming in general. I'm using Visual Studio Community 2015 Desktop Version (from what I know). I can't find a Windows Forms Application from the C++ category, while there is one for C#.
总的来说,我对视觉工作室和编程真的很陌生。我正在使用 Visual Studio Community 2015 桌面版(据我所知)。我在 C++ 类别中找不到 Windows 窗体应用程序,而有一个用于 C#。
Can anyone help, do I need to download another version, a plugin, or anything? Sorry if a stupid question, I just really can't figure it out!
任何人都可以帮忙,我需要下载另一个版本、插件或任何东西吗?对不起,如果一个愚蠢的问题,我真的无法弄清楚!
回答by an earwig
There are no C++ Windows Form templates in Visual Studio 2015. As I see it, you have two choices:
Visual Studio 2015 中没有 C++ Windows 窗体模板。在我看来,您有两种选择:
- When creating a new project, You will see an online dropdown, click that and try to search for "C++ Windows Forms".
Create an empty C++ CLR project and add a Windows Forms to it. This linkputs it like this (credit to the onContentStop, the user who posted this):
- Make a "CLR Empty Project".
- Press Ctrl-Shift-A and create a Windows Form (under UI).
Inside the CPP file that is created, paste this code, replacing anything in square brackets except
[STAThread]
with the appropriate names:#include "[FORM NAME].h" using namespace System; using namespace System::Windows::Forms; [STAThread]//leave this as is void main(array<String^>^ args) { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); Application::Run(gcnew [PROJECT NAME]::[FORM NAME]); }
Right click your project in the Solution Explorer and click Properties.
- Under Configuration Properties > Linker > Advanced, change Entry Point to "main" (without quotation marks).
- Under Configuration Properties > Linker > System, change SubSystem to "Windows (/SUBSYSTEM:WINDOWS)" (without quotation marks).
- 创建新项目时,您将看到一个在线下拉列表,单击它并尝试搜索“C++ Windows 窗体”。
创建一个空的 C++ CLR 项目并向其中添加一个 Windows 窗体。这个链接是这样写的(归功于发布此内容的用户 onContentStop):
- 制作一个“CLR 空项目”。
- 按 Ctrl-Shift-A 并创建一个 Windows 窗体(在 UI 下)。
在创建的 CPP 文件中,粘贴此代码,替换方括号中的任何内容,除了
[STAThread]
适当的名称:#include "[FORM NAME].h" using namespace System; using namespace System::Windows::Forms; [STAThread]//leave this as is void main(array<String^>^ args) { Application::EnableVisualStyles(); Application::SetCompatibleTextRenderingDefault(false); Application::Run(gcnew [PROJECT NAME]::[FORM NAME]); }
在解决方案资源管理器中右键单击您的项目,然后单击属性。
- 在配置属性 > 链接器 > 高级下,将入口点更改为“main”(不带引号)。
- 在配置属性 > 链接器 > 系统下,将子系统更改为“Windows (/SUBSYSTEM:WINDOWS)”(不带引号)。
回答by Shaun Reed
Though this has already been answered, I feel like this might help those who stumble across this in the future. While creating a new project, directly above the text field for naming your project, there is a blue link that reads "Click here to go online and find templates" If you click that link it will direct you to templates that are available for you to download & use. Simply use the hierarchy on the left hand side and navigate to Visual C++ and you should be able to simply click "C++ Windows Forms" and it will create the new project, while also downloading and installing the template for future use. So, next time you go to create a C++ Winform you wont have to search for it again.
虽然这已经得到了回答,但我觉得这可能会帮助那些在未来偶然发现的人。创建新项目时,在用于命名项目的文本字段正上方,有一个蓝色链接,上面写着“单击此处上网并查找模板”。如果单击该链接,它会将您定向到可供您使用的模板下载和使用。只需使用左侧的层次结构并导航到 Visual C++,您应该能够简单地单击“C++ Windows 窗体”,它将创建新项目,同时还下载和安装模板以供将来使用。因此,下次您创建 C++ Winform 时,您不必再次搜索它。
回答by Gaurav
- Click File-New-Project
- Click online
- Click/ Expand Visual C++
- Click windows form application
- Click C++/CLR Windows Forms fur Visual Studio 201..
- 单击文件-新建-项目
- 点击在线
- 单击/展开 Visual C++
- 单击窗体应用程序
- 单击 C++/CLR Windows Forms 和 Visual Studio 201..
Write project Name And Click OK.
写入项目名称并单击“确定”。
Download and enjoy!!
下载并享受!