如何在VS2012中创建一个C ++ / CLI Winforms应用程序? [英] How do I create a C++/CLI Winforms app in VS2012?

查看:437
本文介绍了如何在VS2012中创建一个C ++ / CLI Winforms应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚安装了Visual Studio 2012 express for Desktop。我看不到任何地方创建一个GUI应用程序与C + +!这个Windows窗体应用程序在哪里曾经存在于Visual C ++ 2010?这些拖放控件在哪里?我安装了这个,因为我有详细信息告诉这支持GUI intellisense( Visual C ++:无法从另一个类调用方法

I just installed Visual Studio 2012 express for Desktop. I can't see any place to create a GUI application with C++ ! Where is this "Windows Form Application" used to exists in Visual C++ 2010 ? Where are these drag and drop controls? I installed this because I got details telling this supports GUI intellisense (Visual C++: Unable to invoke method from another class)

请帮助!

推荐答案

这是一个不太明确的提示,他们希望你停止创建C ++ / CLI Winforms应用程序。管道仍然到位,至少VS2012和VS2013。

It is an unsubtle hint that they want you to stop creating C++/CLI Winforms applications. The plumbing is still in place however, at least for VS2012 and VS2013. This might not be the case in a future one.

您可以通过以下步骤将CLR控制台应用程序转换为Winforms应用程序:

You can turn a CLR console application into a Winforms application with these steps:


  • 从文件+ New +项目,CLR节点,CLR控制台应用程序开始

  • 项目+添加新项目,UI节点, / li>
  • 项目+属性,链接器,系统,子系统= Windows

  • 项目+属性,链接器,高级,入口点=主
  • $ b

更改预生成的.cpp文件,如下所示:

Change the pre-generated .cpp file to look like this:

#include "stdafx.h"
#include "MyForm.h"

namespace ConsoleApplication45 {    // Change this!!
    using namespace System;
    using namespace System::Windows::Forms;

    [STAThread]
    int main(array<System::String ^> ^args)
    {
        Application::EnableVisualStyles();
        Application::SetCompatibleTextRenderingDefault(false); 
        Application::Run(gcnew MyForm());
        return 0;
    }
}

注意,您需要更改命名空间名称到您的项目名称。按F5进行测试。一旦一切都结束,您就可以将表单设计为正常。

Note that you'll need to change the namespace name to your project name. Press F5 to test. You can design the form as normal once everything checks out.

这篇关于如何在VS2012中创建一个C ++ / CLI Winforms应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆