2015/10/06

Visual Studio 2013 如何建立C++ windows form

參考來源:http://stackoverflow.com/questions/21411926/how-to-create-a-new-windows-forms-application-project-in-visual-c-2013-ultimat


The following are the steps to make such a project:
  1. Go in the menu bar: File => New => Project, to get a list of project templates.
  2. Select in the tree to the left go: Templates => Visual C++. Select on the right of the of the window of the templates list : Empty Project (Visual C++) .
  3. There will be in the "Solution Explorer" a new tree of files which belong to your new project. Expand it. Let's say you got a new project named "Project1". You'll get on the top of the tree "Solution Project1 (1 project)" . After expanding the tree, You should get on the top of the expansion something called "Project1" right under "Solution Project1 (1 project)" . Right-click "Project1". Select "Add New Item" from the right-click menu.
  4. In "Add New Item" from, in the tree to the left , go : Visual C++ => UI => Windows Forms. click save. You'll get the question "You are adding a CLR component to a native project. The project will be converted to have Common Language Runtime support. Do you want to continue?" . Click "Yes" . Again, one more time, right-click "Project1" and go "Properties".
  5. On the tree to left, go : Configuration Properties => Linker => System. And to the right of the properties window set "SubSystem" as "Windows (/SUBSYSTEM:WINDOWS)" .
  6. Also go: Configuration Properties => Linker => Advanced . And to the right of the properties window, set "Entry Point" to "main". If you cannot not see "Entry Point", just re-open the properties window again. This is the function "main" given below. this is where you're application will start running from.
  7. Finally, Double-click the form designer and move the cursor to the bottom of the code just right before the closing brace of "namespace Project1". Paste the following code. Please remember to rename the variables of this code according to your project needs to get it working with the empty form.
    [STAThread]
    void main(array<String^>^ arg) {
        Application::EnableVisualStyles();
        Application::SetCompatibleTextRenderingDefault(false);
    
        MyForm form;
        Application::Run(%form);
    }
    PS:7的部份是指要放在namespace的{}裡面喔。放外面會爆炸的。


怎麼搞的這麼難用,阿明明就在為啥不直接秀出來就好XD


沒有留言: