zoukankan      html  css  js  c++  java
  • Create C++ Windows Forms Application in Visual Studio 2017

    Background:

    From Windows Forms Application in Visual C++ ???!!!!:

    "MS removed the WinForms C++/CLI template starting in either VS2012 or VS2013.  The official explanation is that they want to encourage managed desktop UI development in C# or VB and relegate C++/CLI to serve as glue between native back end code and managed UI code."

    But for some reason, there are still many people who have reason to create a Windows Forms project of type C++/CLI, for these people, the following steps will show you how to start a C++/CLI Windows Forms app in Visual Studio 2017.

    Environmental configuration:

    Modify your Visual Studio 2017 installer and make sure your Visual Studio 2017 have installed C++ package with C++/CLR:

    Create new project:

    1, If you have installed all the package and components, then open Visual Studio 2017 and create a new project:

    2, You need to configure some properties first, right click on the Project and choose Properties option:

    Add new item:

    1, Right click on the project to add a new item, select UI under Visual C++,then choose Windows Form:

    In general, you will get error as below in this step:

    2, Don't worry, close it and add the following code to the MyForm.cpp:

    using namespace System;
    using namespace System::Windows::Forms;
    
    [STAThreadAttribute]
    void Main(array<String^>^ args) {
                   Application::EnableVisualStyles();
                   Application::SetCompatibleTextRenderingDefault(false);
                   Project1::MyForm form;
                   Application::Run(%form);
    }

    3, After that, save it and close the Visual Studio, then reopen your Project. Note that when you reopen your Project, remember to build(or run directly) it first:

    4, Now you can do your options in the form by double click MyForm.h:

  • 相关阅读:
    python字符串,数组操作
    python爬虫之有道在线翻译
    英雄联盟界面
    学习photoshop心得
    linux命令总结之lsof命令
    linux命令总结之netstat命令
    linux命令总结之route命令
    linux命令总结之ip命令
    linux命令总结之dig命令
    IP地址的分类——a,b,c 类是如何划分的
  • 原文地址:https://www.cnblogs.com/jizhiqiliao/p/10071703.html
Copyright © 2011-2022 走看看